Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - frexp() return mantissa and exponent of numeric http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 frexp()             Return mantissa and exponent of numeric
------------------------------------------------------------------------------
 Declaration
   math.hdr

 Syntax
   func dbl frexp extern
   param value dbl eNumber, ;
               int iExp

 Arguments
   eNumber is a numeric expression.
   iExp is an integer variable to stored the returned exponent.

 Return
   The mantissa of the passed eNumber value.

 Description
   The frexp() function separates the value of the eNumber parameter
   into a mantissa (m) and an exponent (e). The absolute value of (m) will
   be greater than or equal to 0.5 and less than 1.0: (e) will be the power
   of 2 exponent, and the following expression will be true:

                     ( 'x' == (m) * 2 ** (e) )

   where ** means "raised to the power of".

   The parameter iExp is set to the exponent (e), and the mantissa (m)
   is returned. If eNumber is zero, then iExp is set to 0 and 0.0 is
   returned as the mantissa.

   Upon function return the value of the __matherror system variable can
   be tested for error values.

 Example
   #define EXAMPLE_MATH
   #include example.hdr

   // The following statements calculate the mantissa and exponent for
   // some floating-point values.
   
   proc Test_frexp
   vardef
      int iExp
   enddef
   ? frexp(    8.0, iExp ), iExp       //  =  0.5000, iExp =   4
   ? frexp(    0.0, iExp ), iExp       //  =  0.0000, iExp =   0
   ? frexp(  -32.5, iExp ), iExp       //  = -0.5078, iExp =   6
   ? frexp( 1.0e-9, iExp ), iExp       //  =  0.5369, iExp = -29
   endproc

   proc main
   Test_frexp()
   endproc

See Also: __matherror ldexp()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson