FloatToBinary (Float function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(28 intermediate revisions by 4 users not shown)
Line 1: Line 1:
This [[Intrinsic classes|intrinsic]] function converts a numeric value to the binary string equivalent
{{Template:Float:FloatToBinary subtitle}}
of its floating point representation.


The FloatToBinary function is available as of version 7.5 of the [[Sirius Mods]].
The <var>FloatToBinary</var> [[Intrinsic classes|intrinsic]] function converts a numeric value to the binary string equivalent of its floating point representation.
===FloatToBinary syntax===
  %str = number:FloatToBinary
====Syntax terms====
<dl>
<dt>%str
<dd>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.
<dt>number
<dd>A Float value.


</dl>
==Syntax==
===Usage Notes===
{{Template:Float:FloatToBinary syntax}}
The inverse of the FloatToBinary method is [[BinaryToFloat (String function)|BinaryToFloat]].


===Examples===
===Syntax terms===
The following program demonstrates the FloatToBinary method.
<table class="syntaxTable">
    begin
<tr><th>%string</th>
      %i is float
<td>A string variable to receive the converted value of the method object number. Since all <var>Float</var> types are processed in <var class="product">Model 204</var> as Float Len 8, <var>FloatToBinary</var> always returns an 8-byte string. </td></tr>
      for %i from -5.5 to 5.5 by 1.1
 
          [[Intrinsic classes#printtext|printText]] {%i:[[Right (String function)|right]](5)}: {~} = {%i:floatToBinary:stringToHex}
<tr><th>float</th>
      end for
<td>A <var>Float</var> value.</td></tr>
    end
</table>
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===
==Usage notes==
[[List of Intrinsic Float Methods]]
<ul>
[[Category: Intrinsic Float methods|FloatToBinary function]]
<li><var>FloatToBinary</var> is available as of <var class="product">[[Sirius Mods|Sirius Mods]]</var>  Version 7.5.
[[Category: Intrinsic methods]]
</ul>
[[Category: System methods]]


==Examples==
The following program demonstrates the <var>FloatToBinary</var> method.
<p class="code">begin
    %i is float
    for %i from -5.5 to 5.5 by 1.1
      [[PrintText statement|printText]] {%i:[[Right_(String_function)|right]](5)}: {~} = {%i:floatToBinary:stringToHex}
    end for
end
</p>
The result is:
<p class="output">-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
</p>


==See also==
<ul>
<li>The inverse of <var>FloatToBinary</var> is <var>[[BinaryToFloat (String function)|BinaryToFloat]]</var>.
</ul>


<!--
{{Template:Float:FloatToBinary footer}}
<section begin=dpl_desc />
Convert to string with binary representation of Float value
<section end=dpl_desc />
-->

Latest revision as of 17:41, 2 November 2012

Binary string containing floating point representation (Float class)


The FloatToBinary intrinsic function converts a numeric value to the binary string equivalent of its floating point representation.

Syntax

%string = float:FloatToBinary

Syntax terms

%string 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.
float A Float value.

Usage notes

  • FloatToBinary is available as of Sirius Mods Version 7.5.

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