toNumeric

Cast a value to a number.

toNumeric(value [, radix]) → returns numeric

This function requires Lucee. Not supported on Adobe ColdFusion.

toNumeric Argument Reference

value any
Required

radix any
Default: 10

The base of the value.
Values:
  • 2
  • ...
  • 36
  • bin
  • oct
  • dec
  • hex

Examples sample code invoking the toNumeric function


Cast a string to a number.

toNumeric("29.5")

Expected Result: 29.5


Cast a hex-value to a number.

toNumeric("FF0011", "hex")

Expected Result: 16711697


Cast a binary-value to a number.

toNumeric("1010", "bin")

Expected Result: 10


Fork me on GitHub