Core Function Dec

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Example)
(Example)
 
(2 intermediate revisions by one user not shown)
Line 26: Line 26:
  
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
$result = Hex(1033);
+
$result = Dec("409");
println($result); // prints "409"
+
println($result); // prints "1033"
 
+
$result = Hex(1033, 4);
+
$result = Dec("0409");
println($result); // prints "0409"
+
println($result); // prints "1033"
 
+
$result = Hex(1033, 8);
+
$result = Dec("AABB");
println($result); // prints "00000409"
+
println($result); // prints "43707"
</syntaxhighlight>
+
 
+
Example with cast on a $variable
+
 
+
<syntaxhighlight lang="sputnik">
+
$var = 1033;
+
 
+
$result = Hex((int)$var);
+
println($result); // prints "409"
+
 
+
$result = Hex((int)$var, 4);
+
println($result); // prints "0409"
+
 
+
$result = Hex((int)$var, 8);
+
println($result); // prints "00000409"
+
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Latest revision as of 11:50, 16 September 2015

Dec( <expression> )

Contents

Description

Returns a integer representation of a hexadecimal string.

Parameters

expression

The hexadecimal string to convert.

Return Value

Success: Returns an integer.

Failure: Returns 0.

Remarks

The function only works with numbers that fit in a 32 bit signed integer.

Example

$result = Dec("409");
println($result); // prints "1033"
 
$result = Dec("0409");
println($result); // prints "1033"
 
$result = Dec("AABB");
println($result); // prints "43707"
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox