cancel
Showing results for 
Search instead for 
Did you mean: 

Formatted Decimal Number

Former Member
0 Kudos

HI,

I will be able to format a printed field with a dynamic number of decimal, all and only the significant decimal digits.

i.e.:

numeric value: 1,234.10 - printed field: 1,234.1

numeric value: 1234.00 - printed field: 1,234

numeric value: 1234.567 - printed field: 1,234.567

numeric value: .567 - printed field: 0.567

Itu2019s possible?

Thanks

Giovanni

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

This is about as close as I could get. The three decimal value will be rounded up or down and the number of decimal places also depends on your settings. Mine are always set up for two decimals and rounded by 0.01 by default.

 numbervar a := 1234.10;

 if totext(a)[1] in [ '.', '0' ] then '0.' & split(totext(a),'.')[ 2 ]
else
if remainder(a,int(a)) = 0 then (totext(a,0,',',''))
else
if split(totext(a),'.')[ 2 ][length(split(totext(a),'.')[ 2 ])] = '0' then 
totext(a,length(split(totext(a),'.')[ 2 ])-1,',','.')
else
totext(a,length(split(totext(a),'.')[ 2 ]),',','.'); 

Edited by: Sanjay Kodidine on Feb 27, 2009 8:05 PM

Edited by: Sanjay Kodidine on Feb 27, 2009 8:07 PM

Former Member
0 Kudos

Thank you, i try this code.

Giua

Answers (0)