Retro Rocket OS
BASIC-Powered Operating System
Loading...
Searching...
No Matches
HEXVAL Function
integer-value = HEXVAL(string-value)

Returns the integer value of a string containing a hexadecimal number. The string must consist only of valid hex digits (0–9, A–F, a–f).


Examples

PRINT HEXVAL("FF")

Produces 255.

PRINT HEXVAL("deadbeef")

Produces 3735928559.

REM Convert user input
INPUT "Enter a hex number > " ; h$
val = HEXVAL(h$)
PRINT "You entered decimal "; val
REM Round-trip using HEX$
n = &2A REM hex literal in source
h$ = HEX$(n)
PRINT h$; " = "; HEXVAL(h$)

Notes

  • Parsing is case-insensitive: "FF", "Ff", and "ff" all return 255.
  • Returns a 64-bit integer.
  • If the string is empty, or contains any non-hex character, the return value is 0.

See also: HEX$ · STR$