-
Notifications
You must be signed in to change notification settings - Fork 16
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
Odd integer division rounding behavior #223
Comments
That's fascinating. In your domain, the convention is round 0.5 down to zero? I think it is arbitrary, but I'm more familiar with the convention of rounding 0.5 up to 1! For the Doenet component |
Hi Duane
I’ll go look it up but I recall there being a IEEE standard for how this is done in computers. Rounding has three primary styles as I recall.
I’ll look it up. If it’s useful, then the terminology the IEEE invented might be useful to you.
Peace,
Steve
On Jul 23, 2024, at 8:00 PM, Duane Nykamp ***@***.***> wrote:
Caution:
This email originated from outside of FUS. Do not click links, open attachments, or provide any information based on this email unless you know or can verify the sender and know the contents are safe.
That's fascinating. In your domain, the convention is round 0.5 down to zero? I think it is arbitrary, but I'm more familiar with the convention of rounding 0.5 up to 1!
For the Doenet component <round>, we could always add an attribute to specify the behavior of rounding 0.5. But, for the math function round(x), I can't think of a way to make it flexible, as it would be a strange approach to add an extra argument to determine this behavior.
—
Reply to this email directly, view it on GitHub<#223 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AW6NZVGLUU7X4IPR2DFKZC3ZN3VBJAVCNFSM6AAAAABLLMALFGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENBWGU3TKMZQGM>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Doenet definitely started with a focus on math, so I didn't consult IEEE standards. Just looked up IEEE 754. If one implements roundTiesToEven, then 0.5 should be rounded to 0. If one implements roundTiesToAway, then 0.5 should be rounded to 1. It looks like for decimal formats, the default is language defined, but they recommend roundTiesToEven. (For binary formats, they require roundTiesToEven.) From section 4.3.3:
I feel like I should consult with additional stakeholders to know how to proceed. If math folks don't have strong opinions, then it would make sense to follow the IEEE recommendations. |
I had to do odd work-arounds to get integer division to behave normally.
When $totalValue is 1, these two formulations do not compute the same result (I think they should both be zero). See the following DoenetML code snippet:
1
($totalValue)/2
vs.
($totalValue-0.1)/2
In the first case, $quo0 is set to 1; in the second $quo1 is set to 0. Shouldn't they both compute zero?
In normal rounding or truncation, if the dividend from 1/2 = 0.50 or less, then the integer conversion of this result should be zero. Why in the first case is it 1?
The text was updated successfully, but these errors were encountered: