issue with roundup
I had a strange issue with Roundup function. The roundup is broken for numbers less than 0.1 (roundup to 0 instead of 1) when I calculate a decimal number and round it up to assign to a second attribute. However when I did a 2nd project using the same roundup statement and assign to a third attribute, it worked! I really want to understand the issues here since this problem is really hard to detect! It's causing unwanted result without us knowing for a while. Appreciate any input!
My WUID# W20210318-101352 (alpha dev).
Best regards,
Michelle
My WUID# W20210318-101352 (alpha dev).
Best regards,
Michelle
- gogreen
- Posts: 1
- Joined: Fri May 18, 2012 12:45 pm
Michelle,
Please post your code that demonstrates this problem.
Remember, this is a globally public forum, so internal LNRS workunit IDs are unavailable to anyone outside LNRS (and many inside that do not have access to your work environment).
Also, the ROUNDUP() docs say:
So that "regardless of sign" means that this code is all correct:
HTH,
Richard
Please post your code that demonstrates this problem.
Remember, this is a globally public forum, so internal LNRS workunit IDs are unavailable to anyone outside LNRS (and many inside that do not have access to your work environment).
Also, the ROUNDUP() docs say:
The ROUNDUP function returns the rounded integer of the realvalue by rounding any decimal portion to the next larger integer value, regardless of sign.
So that "regardless of sign" means that this code is all correct:
- Code: Select all
DECIMAL5_2 Pos := 2.2;
DECIMAL5_2 Neg := -2.2;
ROUNDUP(Pos); //3
ROUNDUP(Neg); //-3
HTH,
Richard
- rtaylor
- Community Advisory Board Member
- Posts: 1619
- Joined: Wed Oct 26, 2011 7:40 pm
Michelle,
To expand on my previous reply, if what you need is a true "round up" that works on both positive and negative numbers, then here's my solution:
HTH,
Richard
To expand on my previous reply, if what you need is a true "round up" that works on both positive and negative numbers, then here's my solution:
- Code: Select all
DECIMAL5_2 Pos := 2.2;
DECIMAL5_2 Neg := -2.2;
ROUNDUP(Pos); //3
ROUNDUP(Neg); //-3
MyRoundUp(REAL8 r) := IF(r < 0,TRUNCATE(r),ROUNDUP(r));
MyRoundUp(Pos); //3
MyRoundUp(Neg); //-2
HTH,
Richard
- rtaylor
- Community Advisory Board Member
- Posts: 1619
- Joined: Wed Oct 26, 2011 7:40 pm
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest