FRAC returns, as a DOUBLE, the fractional portion of a floating-point number.
Syntax:RetVal = FRAC(Number) Return Value:Parameters: |
CLS PRINT DecToFtInch$(17.14261) FUNCTION DecToFtInch$ (DecMeasure!) DIM Frak! DIM Ft% DIM Inch% DIM Sixteenths% DIM Reduce$ DIM Result$ Frak! = FRAC(DecMeasure!) Ft% = INT(DecMeasure!) Inch% = INT(12 * Frak!) Sixteenths% = INT(16 * FRAC(12 * Frak!)) Reduce$ = TRIM$(STR$(Sixteenths%)) & "/16" SELECT CASE Reduce$ CASE "0/16" : Reduce$ = "" CASE "2/16" : Reduce$ = "1/8" CASE "4/16" : Reduce$ = "1/4" CASE "6/16" : Reduce$ = "3/8" CASE "8/16" : Reduce$ = "1/2" CASE "10/16" : Reduce$ = "5/8" CASE "12/16" : Reduce$ = "3/4" CASE "14/16" : Reduce$ = "7/8" END SELECT Result$ = STR$(Ft%) & "'" & STR$(Inch%) & "-" & Reduce$ Result$ = RTRIM$(Result$, ASC("-")) & CHR$(34) FUNCTION = Result$ END FUNCTION
17' 1-11/16"
FRACL returns, as an LDOUBLE, the fractional portion of a floating-point number.
Syntax:RetVal = FRACL(Number) Return Value:
Parameters: |
DIM RetVal AS LDOUBLE DIM TheNumber AS LDOUBLE TheNumber = 12.12345678901234567890L PRINT "Full value :"; TheNumber RetVal = FRACL(TheNumber) PRINT "Fractional part: "; RetVal
Full value : 12.12345678901234568 Fractional part: 0.1234567890123456791