.Nd number of decimals

Top  Previous  Next

This attribute controls the decimals in numerical items in the put output.  It is addressed using the syntax

 

Localfileidentifier.nd=number;

 

or in the example putex6.gms

 

my1.nw=2;

Example:

Using the example putex6.gms

 

scalar number regnumber /1.2356/

       smallnumber /0.00000001/

       largenumber /1000000000/;

put 'start number here       $':0 number '$ end here'/;

put 'start small number here $':0 smallnumber '$ end here'/;

put 'start large number here $':0 largenumber '$ end here'/;

 

In turn when we run this with the default for .nd of 2 we get

 

start number here       $        1.24$ end here

start small number here $        0.00$ end here

start large number here $1.0000000E+9$ end here

 

showing that by default 2 decimals are printed, unless the number is too large and is moved into exponential format.  It also shows numbers are rounded.  Note small numbers can also be suppressed with nz.

 

If we reset nd to 0 we get

 

start number here       $           1$ end here

start small number here $           0$ end here

start large number here $  1000000000$ end here