Hex: Difference between revisions
Jump to navigation
Jump to search
Kaplanerkan (talk | contribs) |
|||
Line 32: | Line 32: | ||
NSB.Print("1 in hex: " + Hex(1)); | NSB.Print("1 in hex: " + Hex(1)); | ||
NSB.Print("2605.45 in hex: " + Hex(2605.45)); | NSB.Print("2605.45 in hex: " + Hex(2605.45)); | ||
</pre> | |||
== Output == | == Output == |
Revision as of 20:38, 19 May 2013
Hex(number)
Description
Hex returns a string representation of the hexadecimal (base 16) value of a number. The required parameter, number, is any numeric expression. If number is not a whole number, it is rounded to the nearest whole number before being converted.
Example (Basic)
Rem Hex Example 'Hex returns a number as a hexadecimalstring Print "68 in hex:", Hex(68) Print "1 in hex:", Hex(1) Print "2605.45 in hex:", Hex(2605.45)
Example (JavaScript)
// Hex Example /* Hex returns a number as a hexadecimalstring */ function Hex(n) { n=Math.round(n); if (n < 0) { n = 0xFFFFFFFF + n + 1; } return n.toString(16).toUpperCase(); } NSB.Print("68 in hex: " + Hex(68)); NSB.Print("1 in hex: " + Hex(1)); NSB.Print("2605.45 in hex: " + Hex(2605.45));
Output
68 in hex: 44 1 in hex: 1 2605.45 in hex: A2D