tags:

views:

158

answers:

2

is there a way of formatting a string to show whole numbers of a decimal number if it follows 00.

example show 10 if number is 10.00. but show 10.2 if number is 10.2

this is for c#, asp.net

+1  A: 

In .NET:

if (Math.Floor(d) == d)
    return d.ToString("0");
else
    return d.ToString();
Patrick McDonald
A: 

Of course there is:

(if (!= 0 (- (string-to-number x) (floor (string-to-number x))))
    (number-to-string (string-to-number x))
    x)
soulmerge