zero Method

Class: Number

Description

This method formats the number by filling in zeros to obtain the specified field width.

Syntax

NumberObject.zero(Number length,Number decimal,

Boolean implied,Number sign)

Parameters

length

The length of the result.

decimal

The number of decimal places in the result. Rounding to the nearest value is applied, if needed.

implied

An option that indicates how decimal values appear in the result:

  • 0 - The decimal dot appears in the result

  • 1 - The decimal dot appears does not appear in the result because its position is implied.

sign

A number that indicates the position of the sign.

  • 0 - No special treatment of the sign. Leading zeros are inserted before the sign.

  • 1 - Leading sign. All results are signed, and the sign occurs in the first position.

  • 2 - Trailing sign. All results are signed, and the sign occurs in the last position.

Returns

An string consisting of digits, sign, and decimal dot only.

When Became Available

Profile v7.0

Example

// Examples with positive and negative values

type Number POS = 16.384

type Number NEG = -51.2

 

// Examples with implied=1

Type String POS10 = POS.zero(7,2,1,0) ==> "0001638"

Type String NEG10 = NEG.zero(7,2,1,0) ==> "00-5120"

Type String POS11 = POS.zero(7,2,1,1) ==> "+001638"

Type String NEG11 = NEG.zero(7,2,1,1) ==> "-005120"

Type String POS12 = POS.zero(7,2,1,2) ==> "001638+"

Type String NEG12 = NEG.zero(7,2,1,2) ==> "005120-"

 

// Examples with implied=0

Type String POS00 = POS.zero(7,2,0,0) ==> 0016.38

Type String NEG00 = NEG.zero(7,2,0,0) ==> 0-51.20

Type String POS01 = POS.zero(7,2,0,1) ==> +016.38

Type String NEG01 = NEG.zero(7,2,0,1) ==> -051.20

Type String POS02 = POS.zero(7,2,0,2) ==> 016.38+

Type String NEG02 = NEG.zero(7,2,0,2) ==> 051.20-