Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The Val() function doesn't recognize system-wide decimal point

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

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

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

Is this a feature or a bug? How can I specify which decimal point will be used in function val()?

like image 223
Tomas Avatar asked Mar 22 '23 21:03

Tomas


1 Answers

According to the documentation:

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

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

like image 163
Tomas Avatar answered Apr 19 '23 21:04

Tomas