$X2D: Difference between revisions

From m204wiki
Jump to navigation Jump to search
No edit summary
 
(16 intermediate revisions by 3 users not shown)
Line 2: Line 2:
<span class="pageSubtitle">Convert hex string to integer</span>
<span class="pageSubtitle">Convert hex string to integer</span>


<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $X2D function is the [[HexToInteger (String function)]] or the [[HexToString (String function)]]. For a full list of string and numeric conversion functions see [[List of String methods]] and [[List of Float methods]].</p>
<p class="warn"><b>Note: </b>Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $X2D function is <var>[[HexToInteger (String function)|HexToInteger]]</var> or <var>[[HexToString (String function)|HexToString]]</var>. For a full list of string and numeric conversion functions see [[List of String methods]] and [[List of Float methods]].</p>


The $X2D function returns the integer which is represented by the hexadecimal input string.  
The <var>$X2D</var> function returns the integer that is represented by the hexadecimal input string.  


$X2D accepts two optional arguments and returns a numeric value.
==Syntax==
 
<p class="syntax"><span class="term">%value</span> = $X2D([<span class="term">hex_string</span>], [<span class="term">width</span>])
The first argument is the hex string to be converted to an integer. If it is omitted or is the null string or contains characters other than '0' through '9', 'A' through 'F', or 'a' through 'f', zero is the result.
</p>
 
The second argument is the number of characters to use from the string. If it is omitted or is greater than 8, 8 characters are used. If, after conversion to an integer, it is 0 or less, or can't be represented as a 31 bit value, zero is the result of $X2D.


The leading bit of the hexadecimal string is repeated out to the length derived from the second argument. If the length is less than the length of the hexadecimal string, the leftmost digits of the hexadecimal string are dropped. The hexadecimal string represents an integer using 2's complement.
===Syntax terms===
<table>
<tr><th>%value</th>
<td>The integer value that is represented by the <var class="term">hex_string</var> hexadecimal string.
<p>
The leading bit of the hexadecimal string is repeated out to the length derived from the <var class="term">width</var> argument. If the length is less than the length of the hexadecimal string, the leftmost digits of the hexadecimal string are dropped. The hexadecimal string represents an integer using 2's complement. </p></td></tr>


==Syntax==
<tr><th>hex_string</th>
<p class="syntax"><section begin="syntax" />%VALUE = $X2D(hex_string, width)
<td>The hex string to be converted to an integer. If it is omitted, or is the null string, or contains characters other than '0' through '9', 'A' through 'F', or 'a' through 'f', <var class="term">%value</var> is zero. </td></tr>
<section end="syntax" /></p>


<p class="caption">%VALUE is set to the integer represented in 2's complement by the hexadecimal string.</p>
<tr><th>width</th>
<td>The number of characters to use from <var class="term">hex_string</var>. If <var class="term">width</var> is omitted or is greater than 8, 8 characters are used. If, after conversion to an integer, it is 0 or less, or can't be represented as a 31 bit value, the result of <var>$X2D</var> is zero. </td></tr>
</table>


==Example==
==Example==
The following program will print the value -1:
The following request will print the value <code>-1</code>:
<p class="code">B
<p class="code">B
PRINT $X2D('0F', 1)
Print $x2d('0F', 1)
END
End
</p>
</p>


<h2>Products authorizing {{PAGENAMEE}}</h2><ul class="smallAndTightList">
==Products authorizing {{PAGENAMEE}}==
<li>[[Sirius functions]]</li>
<ul>
<li>[[List of $functions|Sirius functions]]</li>
<li>[[Fast/Unload User Language Interface]]</li>
<li>[[Fast/Unload User Language Interface]]</li>
<li>[[Janus Open Client]]</li>
<li>[[Media:JoclrNew.pdf|Janus Open Client]]</li>
<li>[[Janus Open Server]]</li>
<li>[[Media:JosrvrNew.pdf|Janus Open Server]]</li>
<li>[[Janus Sockets]]</li>
<li>[[Janus Sockets]]</li>
<li>[[Janus Web Server]]</li>
<li>[[Janus Web Server]]</li>
<li>[[Japanese functions]]</li>
<li>Japanese functions</li>
<li>[[Sir2000 Field Migration Facility]]</li>
<li>[[Media:SirfieldNew.pdf|Sir2000 Field Migration Facility]]</li>
</ul>
</ul>


[[Category:$Functions|$X2D]]
[[Category:$Functions|$X2D]]

Latest revision as of 23:32, 20 September 2018

Convert hex string to integer

Note: Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $X2D function is HexToInteger or HexToString. For a full list of string and numeric conversion functions see List of String methods and List of Float methods.

The $X2D function returns the integer that is represented by the hexadecimal input string.

Syntax

%value = $X2D([hex_string], [width])

Syntax terms

%value The integer value that is represented by the hex_string hexadecimal string.

The leading bit of the hexadecimal string is repeated out to the length derived from the width argument. If the length is less than the length of the hexadecimal string, the leftmost digits of the hexadecimal string are dropped. The hexadecimal string represents an integer using 2's complement.

hex_string The hex string to be converted to an integer. If it is omitted, or is the null string, or contains characters other than '0' through '9', 'A' through 'F', or 'a' through 'f', %value is zero.
width The number of characters to use from hex_string. If width is omitted or is greater than 8, 8 characters are used. If, after conversion to an integer, it is 0 or less, or can't be represented as a 31 bit value, the result of $X2D is zero.

Example

The following request will print the value -1:

B Print $x2d('0F', 1) End

Products authorizing $X2D