Siebel eScript Language Reference > Siebel eScript Commands > Conversion Methods >

toFixed() Method


This function returns a number converted to a specified number of decimal places.

Syntax

numberVar.toFixed(len)

Parameter
Description

len

The number of decimal places to which the number contained in variable numberVar is to be converted

Returns

This function returns the number contained in variable numberVar, expressed to len decimal places. If len is less than the number of significant decimal places of numberVar, then the function applies standard rounding (round up for 5 or greater, else round down). If len is greater than the number of significant decimal places of numberVar, then the function pads the extra places with zeroes. If len is negative, an error is thrown.

Usage

This function allows you to express numbers with a desired number of decimal places; for example, to express results of currency calculations with exactly two decimal places.

Example

The following uses of toFixed() yield the results shown.

var profits=2487.8235
var profits3 = profits.toFixed(3) //returns 2487.824
var profits2 = profits.toFixed(2) //returns 2487.82
var profits7 = profits.toFixed(7) //returns 2487.8235000
var profits0 = profits.toFixed(0) //returns 2488
var profitserr = profits.toFixed(-1) //throws error

See Also

toExponential() Method
toPrecision() Method

Siebel eScript Language Reference