KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: The Num command and the decimal separator
PRODUCT: 4D Developer | VERSION: 11 | PLATFORM: Mac & Win
Published On: September 4, 2008
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

The Num command in 4D v11 SQL accepts a parameter for the decimal separator.

Num (expression; separator) > Number

The decimal separator is interpreted as a decimal place and must be embedded in a numeric string.

In addition using the GET SYSTEM FORMAT you can determine what Decimal separator is being used by the system. For example:

If you have a string:

$numerical_string:="1,458.95"

You use the Num command without the decimal separator parameter, in a system that does not use a period as a decimal separator you will not get the right numeric value.

$numerical_value:=Num($numerical_string)

This will result in 1.45895 in a system using "," as the decimal separator. The same expression with the decimal separator parameter will result in the right numerical value.

$numerical_value:=Num($numerical_string;".")

This will result in 1,458.95 for a system using "." as a decimal separator or 1.458,95 for a system using "," as the decimal separator.

For more information see the Num command documentation:
http://www.4d.com/docs/CMU/CMU00011.HTM