# Deal with floating-point numbers in WRT environment

**Symbian**

## Description

The format of a floating-point number is system language dependent. That is in some languages the radix point symbol is a dot "." and in some languages the radix point symbol is a comma ",". However, the JavaScript engine in WRT never recognizes a comma "," as a radix point of a floating-point number. It does not neither recognize a dot "." as a radix point of a floating-point number if the current system language uses a comma "," as the radix point symbol. Therefore, a defined floating-point number with a dot "." separating the integral part from the fractional part of that number will not always be recognized as a floating-point number. Instead, in those system languages that use a comma as the radix point symbol, the fractional part will be truncated and a floating-point number will become an integer.

E.g. var pi = 3.1416;

pi is 3 in Italian or Finnish system language pi is 3.1416 in English system language

## Solution:

To make your codes work in all system languages, use the following solutions to solve the problem:

* Solution 1:* Let the system create the floating-point number

E.g.

var pi = 3 + 1416/10000; var d = 5 + 8/10; var cir = d * pi;

* Solution 2:* Define a floating-point number as a string, then use the parseFloat() method to convert it to a floating-point number

E.g.

var pi = "3.1416"; var d = "5.8"; var cir = parseFloat(d) * parseFloat(pi);

(no comments yet)