Skip to main content
Solved

ROUNDUP incorrect rounding - take 2

  • September 6, 2023
  • 6 replies
  • 45 views

Forum|alt.badge.img+4

ROUNDUP is returning unexpected results.

See screenshots, there are 3 records where ROUNDUP is increasing the value rather than truncating a '0' (I was expecting 0.070 roundup to be 0.07)  Is this an error, or am I not understanding ROUNDUP correctly?

2nd screenshot added the FLOOR function as suggested in this pos, but had no impact to the results.: Solved: Re: ROUNDUP(number, 2) Incorrect rounding - Airtable Community

thanks for any insights!

Best answer by BillFrench

No, there doesn't seem to be one that would be helpful, but which one specifically?


All of them. This list demonstrates there is a preponderance of evidence that the Java floating point bug is what you may be encountering.

https://ellenaua.medium.com/floating-point-errors-in-javascript-node-js-21aadd897bf8

https://stackoverflow.com/questions/1458633/how-to-deal-with-floating-point-number-precision-in-javascript

6 replies

Forum|alt.badge.img+19
  • Inspiring
  • 3263 replies
  • September 6, 2023

The infamous Java floating point error?


Forum|alt.badge.img+21
  • Inspiring
  • 560 replies
  • September 7, 2023

Are the "Crate Weight" numbers rounded off by format?
That would also change the result.
But why does ROUNDUP turn 0.55000 into 0.56?
I don't usually use ROUNDUP so it's not a problem, but is this a bug?

How about this ugly workaround?

Cut off to 3 decimal place and rounded up to 2 decimal place ROUNDUP(INT({Num}*1000),-1)/1000 Cut off to 4 decimal place and rounded up to 2 decimal place ROUNDUP(INT({Num}*10000),-2)/10000

 


Forum|alt.badge.img+19
  • Inspiring
  • 3263 replies
  • September 7, 2023

Are the "Crate Weight" numbers rounded off by format?
That would also change the result.
But why does ROUNDUP turn 0.55000 into 0.56?
I don't usually use ROUNDUP so it's not a problem, but is this a bug?

How about this ugly workaround?

Cut off to 3 decimal place and rounded up to 2 decimal place ROUNDUP(INT({Num}*1000),-1)/1000 Cut off to 4 decimal place and rounded up to 2 decimal place ROUNDUP(INT({Num}*10000),-2)/10000

 


Have you read these?

https://community.airtable.com/t5/search-results/bd-p/search?searchString=Floating+point+math+error&activeType=all&from=0&sortby=_score&orderBy=desc&pageNo=1&aggregations=%5B%5D&uid=101f6a29-193a-11ed-b8f7-0242ac120006&resultsPerPage=10&exactPhrase=&withOneOrMore=&withoutTheWords=&pageSize=10&language=en&state=7&suCaseCreate=false


Forum|alt.badge.img+21
  • Inspiring
  • 560 replies
  • September 7, 2023

Forum|alt.badge.img+9
  • Participating Frequently
  • 42 replies
  • Answer
  • September 7, 2023

No, there doesn't seem to be one that would be helpful, but which one specifically?


All of them. This list demonstrates there is a preponderance of evidence that the Java floating point bug is what you may be encountering.

https://ellenaua.medium.com/floating-point-errors-in-javascript-node-js-21aadd897bf8

https://stackoverflow.com/questions/1458633/how-to-deal-with-floating-point-number-precision-in-javascript


Forum|alt.badge.img+21
  • Inspiring
  • 560 replies
  • September 7, 2023

All of them. This list demonstrates there is a preponderance of evidence that the Java floating point bug is what you may be encountering.

https://ellenaua.medium.com/floating-point-errors-in-javascript-node-js-21aadd897bf8

https://stackoverflow.com/questions/1458633/how-to-deal-with-floating-point-number-precision-in-javascript


Thanks for the article! The Stackoverflow article was especially helpful.
I don't know much about programming so I didn't know it was a common problem.
In Airtable's case, it seems like a better way to calculate it as an integer for now.