×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Microsoft: FoxPro FAQ

## Usefull Functions & Procedures

 64BIT FLOATING FUNCTIONS by 738262 faq184-1932 Posted: 18 May 02 FUNCTION  Float64ToNumLPARAMETERS Float64 AS STRING*!*        S XXXXXXX XXXX MMMM MMMMMMMM MMMMMMMM MMMMMMMM MMMMMMMM MMMMMMMM MMMMMMMM*!*        0 0000000 0000 0000 00000000 00000000 00000000 00000000 00000000 00000000*!*        1 2345678 9012 3456 78901234*!*            1         2         3LOCAL SIGN AS INTEGERLOCAL Bias AS INTEGERLOCAL Exponent AS INTEGERLOCAL I AS INTEGERLOCAL x AS STRINGLOCAL Mantissa AS NUMBERLOCAL OldDecimals AS INTEGERLOCAL oldFixed AS STRINGIF LEN(Float64)<8  RETURN 0ENDIF*OldDecimals=SET("Decimals")*SET DECIMALS TO 20oldFixed=SET("Fixed")SET FIXED OFFMantissa=1SIGN=0Bias=1023Exponent=0Float64=LEFT(Float64,8)SIGN=IIF(BITTEST(ASC(LEFT(Float64,1)),7),-1,1)FOR I=12 TO 2 STEP -1  Exponent=Exponent+IIF(BITTEST(ASC(SUBSTR(Float64,INT((I-1)/8)+1,1)),7-MOD((I-1),8)),1,0)*(2^(12-I))NEXTExponent=Exponent-1023FOR I=13 TO 64  AA=INT((I-1)/8)+1  BB=7-MOD((I-1),8)  B=IIF(BITTEST(ASC(SUBSTR(Float64,INT((I-1)/8)+1,1)),7-MOD((I-1),8)),1,0)  Mantissa=Mantissa+IIF(BITTEST(ASC(SUBSTR(Float64,INT((I-1)/8)+1,1)),7-MOD((I-1),8)),1,0)*(1/(2^(I-12)))NEXTSET FIXED &oldFixedRETURN SIGN*(Mantissa)*(2^Exponent)ENDFUNCFUNCTION NumToFloat64LPARAMETERS NUMB AS NUMBERLOCAL Float64 AS STRINGLOCAL SIGN AS INTEGERLOCAL Bias AS INTEGERLOCAL Exponent AS INTEGERLOCAL I AS INTEGERLOCAL Y AS INTEGERLOCAL x AS STRINGLOCAL Mantissa AS NUMBERLOCAL oldFixed AS STRINGLOCAL m.byte,m.bitLOCAL fraction AS NUMBERoldFixed=SET("Fixed")SET FIXED OFFMantissa=0SIGN=0Bias=1023Exponent=0Float64=REPLICATE(CHR(0),8)*set singFloat64=STUFF(Float64,1,1,IIF(NUMB<0,CHR(128),CHR(0)))NUMB=ABS(NUMB)I=-1023DO WHILE I<=1023  IF NUMB<2^I    EXIT  ENDIF  I=I+1ENDDOExponent=1023+I-1FOR I=0 TO 11  IF BITTEST(Exponent,I)    m.byte=INT(((12-I)-1)/8)+1    m.bit=7-MOD(((12-I)-1),8)    Float64=STUFF(Float64,m.byte,1,CHR(BITSET(ASC(SUBSTR(Float64,m.byte,1)),m.bit)))  ENDIFNEXTMantissa=NUMB/(2^(Exponent-1023))-1FOR I=1 TO 52  IF Mantissa>=1/(2^I)    m.byte=INT(((I+12)-1)/8)+1    m.bit=7-MOD(((I+12)-1),8)    Float64=STUFF(Float64,m.byte,1,CHR(BITSET(ASC(SUBSTR(Float64,m.byte,1)),m.bit)))    Mantissa=Mantissa-1/(2^I)  ENDIF  IF Mantissa=0    EXIT  endifNEXTSET FIXED &oldFixedRETURN Float64ENDFUNC Back to Microsoft: FoxPro FAQ Index Back to Microsoft: FoxPro Forum

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!