5-Regular Member
August 30, 2023
Solved
Rounding error with trunc() and floor() functions that return exact integers
- August 30, 2023
- 2 replies
- 3121 views
I'm having an issue where I need to do division, then eliminate the decimal portion of the answer and only keep the integer. I've successfully used both trunc() and floor() for this application in the past. But when the quotient results in an exact integer (like 84/12=7 in my example), Mathcad rounds down to 6 instead of returning 7. I'm assuming this is the result of some approximation internal to how Mathcad does division. Like it's really calculating 6.99999999999999... maybe? Are there any work arounds for this? Obviously I can just make the equation 84/12, but this is in a template that I'm trying to make apply to all cases.



