function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RytomRytom 

variable value NaN

Is there a way in APEX to compare a variable to NaN (not a number). 

 

I have some calculations that involve converting values to decibels so there could be cases where the conversion will give me a NaN (converting a negative number to decibels). 

 

I would like to be able to do some checks on whether the converted value is valid or if it is NaN. But whenever I try to use "NaN" in the code it doesn't list it as a valid value, instead thinking I'm trying to use a variable called NaN. 

Vinita_SFDCVinita_SFDC

Hello,

 

I understand you wish to check if the returned value is number or not. You can simply check it with method isNumeric. You can store the boolean value returned from this method in a variable (NaN) and use it for comparison in rest of your code.

 

Refer: http://developer.force.com/releases/release/Winter13/New+String+Methods