BinaryToInteger (String function): Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
|||
Line 8: | Line 8: | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>%number</th> | <tr><th nowrap>%number</th> | ||
<td>A numeric variable to receive the integer value of the method object <var class="term">string</var>.</td></tr> | <td>A numeric variable to receive the integer value of the method object <var class="term">string</var>.</td></tr> | ||
<tr><th>string</th> | <tr><th>string</th> | ||
<td>A binary string value. The string's length must be four characters or | <td>A binary string value. The string's length must be four characters or fewer but greater than zero.</td></tr> | ||
<tr><th><var>Signed</var></th> | <tr><th><var>Signed</var></th> | ||
<td>This | <td>This optional, but [[Notation conventions for methods#Named parameters|name required]], argument is a <var>[[boolean enumeration]]</var> that indicates whether the method object <var class="term">string</var> is to be converted to a signed integer or not. | ||
<ul> | <ul> | ||
<li><var>Signed</var> defaults to <code>False</code>, which produces an unsigned conversion. | <li><var>Signed</var> defaults to <code>False</code>, which produces an unsigned conversion. |
Latest revision as of 15:41, 17 March 2016
Convert a binary string to an integer (String class)
BinaryToInteger is an intrinsic function that treats a string as if it were binary and converts it to an integer. The string may contain no more than four characters.
Syntax
%number = string:BinaryToInteger[( [Signed= boolean])]
Syntax terms
%number | A numeric variable to receive the integer value of the method object string. |
---|---|
string | A binary string value. The string's length must be four characters or fewer but greater than zero. |
Signed | This optional, but name required, argument is a boolean enumeration that indicates whether the method object string is to be converted to a signed integer or not.
|
Usage notes
- The BinaryToInteger function is available as of Sirius Mods version 7.3.
Examples
- The following statement displays
240
:printText {'0':binaryToInteger}
- The following statement displays
61680
:printText {'00':binaryToInteger}
- The result of the following pair of statements is
-3856
:%string = '00' printText {%string:binaryToInteger(signed=true)}
- The result of the following pair of statements is
0
:%string = '00':hexToString printText {%string:binaryToInteger}
See also
- The inverse of BinaryToInteger is IntegerToBinary.