Format command problem?

Hi there… I have a problem with the Format function…

I have this row

result=Format(value,"#,###,##0.###")

If value=1.5, result is 1.5, but if value=2, result is 2. (with the . at the end)

Another problem I found is:

result=Format(value,"#,###,##0")

If value=1.5, result is 2, and if value=2, result is 2

But how can I have 1.5 or 2 (without . at the end)?

Many thanks for your suggestions!

neither of these are “problems”, this is by design
format will round the value to fit the pattern therefore 1.5 shows as two because you provided no pattern for the fractional part
And as discussed on a very recent topic, the decimal point will alway be displayed if specified in the patten

you can do this to “solve” one of the issues you face

result=Format(FLOOR(value),"#,###,##0.###")

refer to the other topics for suggestions about the decimal point

Your suggestion gives me an idea to workaround:

if ceil(value)>value then return=Format(value,"#,###,##0.###") Else return=Format(value,"#,###,##0") end if

I hope this can help any other…

Thanks Dave!

  static nationalDecimalPoint as string = replaceall( format(1.1,"0.0"), "1", "")
  result=Format(value,"#,###,##0.###")
  if result.right(1) = nationalDecimalPoint then
    result = result.Left(result.len() - nationalDecimalPoint.Len())
  end if  

or in ONE line

result=format(x,"#,###,##0"+if(floor(x)=x,"",".##"))