home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OS2BAS.ZIP / FIXED.BAS < prev    next >
BASIC Source File  |  1989-08-30  |  1KB  |  38 lines

  1. '***********************************************************
  2. '* 
  3. '* Program Name: Fixed.BAS
  4. '*
  5. '* Functions   :
  6. '*               IEEEtoFixed
  7. '*               FixedtoIEEE
  8. '*
  9. '* Description : This file provides routines to convert
  10. '*               between BASIC's IEEE floating point numbers
  11. '*               and PM's 32-bit FIXED decimal point numbers.
  12. '*               This is accomplished by multiplying and
  13. '*               dividing by 2^16 (&H10000).
  14. '*
  15. '*               These routines are not equivalent to the C
  16. '*               macro, MAKEFIXED.  These are actually more
  17. '*               intuitive.  For example, to use the C macro
  18. '*               to make a fixed type with the value 1.5,
  19. '*               you would use MAKEFIXED(1,32768) because
  20. '*               32768 is .5 of 2^16.  With these routines,
  21. '*               the fixed value equivalent to 1.5 is
  22. '*               returned by the simple call IEEEtoFixed(1.5)
  23. '***********************************************************
  24.  
  25. '**** IEEEtoFixed takes an IEEE floating point number (BASIC's standard) and
  26. '**   returns a FIXED type used by several of the PM functions
  27.  
  28. FUNCTION IEEEtoFixed&(float AS DOUBLE)
  29.   IEEEtoFixed& = float * &H10000
  30. END FUNCTION
  31.  
  32. '**** FixedtoIEEE takes a FIXED type used by several of the PM functions
  33. '**   and returns an IEEE floating point number (BASIC's standard)
  34.  
  35. FUNCTION FixedtoIEEE#(Fixed AS LONG)
  36.   FixedtoIEEE# = 1# * Fixed / &H10000
  37. END FUNCTION
  38.