Click or drag to resize

Real82Bin Function

Convert a Real8 value to a string containing an 8-byte floating point number.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.2a
Syntax
 FUNCTION Real82Bin(
	r8Value AS REAL8
) AS STRING
View Source

Parameters

r8Value
Type: Double
The value to convert.

Return Value

Type: String
Remarks
Real82Bin() is a conversion function that converts a Real8 data type into an 8-byte string.  Typical applications include reading foreign file types in their native format and then saving, reading, decrypting, and transmitting data in their compressed binary form instead of in strings.  Its inverse is Bin2Real8().
Examples
Instead of saving numeric data as strings, this example writes them in a binary format in order to save disk space and possible transmission times:
X#
FUNCTION Compressed() AS LOGIC
        LOCAL nh
        LOCAL lSuccess := FALSE AS LOGIC
        nh := FOpen2("data.bin", FO_READWRITE)
        // Assumes that file debug.bin already exists
        IF nh != F_ERROR
                FWrite3(nh, Real82Bin(123456.789), 8)
                FWrite3(nh, Real82Bin(12 ^ 6), 8)
                FWrite3(nh, Real82Bin(4566.969), 8)
                FClose(nh)
                lSuccess := TRUE
        ELSE
                ? DOSErrString(siError)
        ENDIF
        RETURN lSuccess
See Also