Val () function does not recognize the decimal point of the entire system

The val() function seems to understand . as a decimal point, even in systems with , as a decimal point. For example, the next call

 val("7,3") + 1,4 

returns a real number of 8,4 ( 8.4 in English notation). val("7.3") + 1,4 returns the expected value of 8,7 .

Is this a sign or a mistake? How to specify which decimal point will be used in val() function?

+4
source share
1 answer

According to the documentation :

Note Val only recognizes the period ( . ) As a valid decimal separator. When using different decimal separators, as in international applications, use CDbl instead to convert the string to a number.

Note: Val(7,3)+1,4 also returns 8,4 , so be careful if your input is already in number format!

+7
source

Source: https://habr.com/ru/post/1495314/


All Articles