hex2num

hex2num(str)

Convert a hexadecimal string to the floating point number it represents

Examples

julia> hex2num("3f800000")
1.0

This example converts the hexadecimal string "3f800000" to the corresponding floating point number, which is 1.0.

julia> hex2num("40490fdb")
3.141592653589793

Here, the hexadecimal string "40490fdb" is converted to the floating point number approximation of π (pi).

julia> hex2num("bff0000000000000")
-1.0

The hexadecimal string "bff0000000000000" is converted to -1.0, representing a negative floating point number.

Common mistake example:

julia> hex2num("abc")
ERROR: ArgumentError: Invalid hexadecimal string

In this example, the provided hexadecimal string "abc" is not a valid hexadecimal representation. Make sure to provide a valid hexadecimal string when using the hex2num function.

See Also

base, big, bytes2hex, cconvert, complex, convert, dec, hex, hex2bytes, hex2num, oct, oftype, parse, promote, signed, unsafe_convert, unsigned, widen,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: