FloatToBinary (Float function): Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
{{Template:Float:FloatToBinary subtitle}} | |||
This [[Intrinsic classes|intrinsic]] function converts a numeric value to the binary string equivalent | This [[Intrinsic classes|intrinsic]] function converts a numeric value to the binary string equivalent | ||
of its floating point representation. | of its floating point representation. | ||
The FloatToBinary function is available as of version 7.5 of the [[Sirius Mods]]. | The FloatToBinary function is available as of version 7.5 of the [[Sirius Mods]]. | ||
== | ==Syntax== | ||
{{Template:Float:FloatToBinary syntax}} | |||
===Syntax terms=== | |||
<dl> | <dl> | ||
<dt>%str | <dt>%str | ||
Line 17: | Line 19: | ||
</dl> | </dl> | ||
==Usage notes== | |||
The inverse of the FloatToBinary method is [[BinaryToFloat (String function)|BinaryToFloat]]. | The inverse of the FloatToBinary method is [[BinaryToFloat (String function)|BinaryToFloat]]. | ||
==Examples== | |||
The following program demonstrates the FloatToBinary method. | The following program demonstrates the FloatToBinary method. | ||
begin | begin |
Revision as of 13:42, 19 January 2011
Binary string containing floating point representation (Float class)
This intrinsic function converts a numeric value to the binary string equivalent
of its floating point representation.
The FloatToBinary function is available as of version 7.5 of the Sirius Mods.
Syntax
%string = float:FloatToBinary
Syntax terms
- %str
- A string variable to receive the converted value of the method object number. Since all Float types are processed in Model 204 as Float Len 8, FloatToBinary always returns an 8-byte string.
- number
- A Float value.
Usage notes
The inverse of the FloatToBinary method is BinaryToFloat.
Examples
The following program demonstrates the FloatToBinary method.
begin %i is float for %i from -5.5 to 5.5 by 1.1 printText {%i:right(5)}: {~} = {%i:floatToBinary:stringToHex} end for end
The result is:
-5.5: %i:floatToBinary:stringToHex = C158000000000000 -4.4: %i:floatToBinary:stringToHex = C146666666666666 -3.3: %i:floatToBinary:stringToHex = C134CCCCCCCCCCCC -2.2: %i:floatToBinary:stringToHex = C123333333333333 -1.1: %i:floatToBinary:stringToHex = C111999999999999 0: %i:floatToBinary:stringToHex = 0000000000000000 1.1: %i:floatToBinary:stringToHex = 4111999999999999 2.2: %i:floatToBinary:stringToHex = 4123333333333333 3.3: %i:floatToBinary:stringToHex = 4134CCCCCCCCCCCC 4.4: %i:floatToBinary:stringToHex = 4146666666666666 5.5: %i:floatToBinary:stringToHex = 4158000000000000
See also
List of intrinsic Float methods