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.6
Syntax
 FUNCTION Real82Bin(
	r8Value AS REAL8
) AS STRING
Request Example 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#
 1FUNCTION Compressed() AS LOGIC
 2    LOCAL nh
 3    LOCAL lSuccess := FALSE AS LOGIC
 4    nh := FOpen2("data.bin", FO_READWRITE)
 5    // Assumes that file debug.bin already exists
 6    IF nh != F_ERROR
 7        FWrite3(nh, Real82Bin(123456.789), 8)
 8        FWrite3(nh, Real82Bin(12 ^ 6), 8)
 9        FWrite3(nh, Real82Bin(4566.969), 8)
10        FClose(nh)
11        lSuccess := TRUE
12    ELSE
13        ? DOSErrString(siError)
14    ENDIF
15    RETURN lSuccess
See Also