Formatnumber(14.89,0) Is Rounding To 15 追蹤

0
Avatar
Legacy Poster

 
FormatNumber(14.89,0) is rounding to 15  
is this the expected behavior.
I'm using now ver 10.1 im almost sure this is not the way it worked in the past  
 
yona

1 意見

0
Avatar
Michael Toupin (mtoupin
評論操作 永久連結

Yes, that's correct.  What FormatNumber does is rounds to the nearest digit, and adds commas at each thousandths place ( so FormatNumber(12345.678,2) would result in 12,345.68).  FormatCurrency works the same way, but with the addition of a currency symbol at the beginning of the number.  Setting the number of decimal places to 0 will result in a rounded whole number.

 

If your intention is to just show the whole number, you'd want to use a script like value = mid(data, 1, (instr(data,".") - 1)).  This will just delete anything from the decimal point on.  

登入寫評論。