-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
round(num,2) not rounding #5
Comments
I added a test for this to
The results of the first two, the subtraction and the multiplication, aren’t representable in floating point, as you can see here:
However, the expected result of the round operation, 14.29, is representable. The error is introduced by JavaRosa’s rounding algorithm
giving these values:
There’s the explanation. Now what shall we do about it? I’m inclined to consider an approach like this:
I wonder why JavaRosa’s round function doesn’t do it this way. Performance? NumberFormat not being available on Android? |
I can't see any obvious reasons it wouldn't have been done that way. It looks like all the required functionality has been in Java since the beginning of Java. It could have maybe been performance in the J2ME days but I can't imagine that'd still be a problem. @mitchellsundt @yanokwa any reason not to use |
I don't know offhand. For what it's worth, here's what CommCare does... |
CommCare’s round takes just one argument. Ours takes 2.
versus
One of our code comments: |
I have implemented a solution. See 7d0e596. |
Closed in #33 |
Issue by mitchellsundt
Thursday Jul 09, 2015 at 19:41 GMT
Originally opened as getodk/getodk#1030 (0 comment(s))
Originally reported on Google Code with ID 1029
Reported by
yanokwa@nafundi.com
on 2014-07-02 17:14:41- _Attachment: [Basic.xml](https://storage.googleapis.com/google-code-attachments/opendatakit/issue-1029/comment-0/Basic.xml)_
The text was updated successfully, but these errors were encountered: