transit Posted October 8, 2003 Posted October 8, 2003 Hi all Does anyone know how to round a figure up or down to for example 2 decimal places. I understand the function: Round (number, precision)but what I need is to be able to round a figure like 1.2876 down to 1.28 I hope that makes sense to someone. Many thanks
Lee Smith Posted October 8, 2003 Posted October 8, 2003 Hi "Transit" This will do it. Round(Number/ .02,0)*.02 HTH Lee
LaRetta Posted October 8, 2003 Posted October 8, 2003 Hi Transit, In the example you've given 1.2876, you aren't rounding at all but rather truncating to two-digit decimal. If you want to drop everything past the second decimal, try instead: Truncate (number, precision) or Truncate(YourNumberField), 2) This will always leave you with two decimal points. You can include Round in the calculation also if you wish which would give you 1.29 or if the number was 1.2538 would give you 1.25. You can also just leave it as it is and use field format to display only two decimal points. LaRetta
transit Posted October 8, 2003 Author Posted October 8, 2003 Thanks Lee A simple solution! I like them Many thanks
transit Posted October 8, 2003 Author Posted October 8, 2003 Thanks LaRetta It would seem from what you are saying that truncate is for rounding down and round can be used for rounding up or down. I have never used truncate before so thankyou for introducing me to that! The reason I didnt use field format to display only two decimal points was that I was using this field to make further calculations and so needed the rounding down at this point and from what I can gather although it may only display two decimal points it calculates on the full "unrounded" figure, or have I missed somethink? Many thanks
McCormick Posted October 8, 2003 Posted October 8, 2003 Okay, now I'm curious: I get rounding off and rounding down, but how do you round up? Just round down and add one?
-Queue- Posted October 8, 2003 Posted October 8, 2003 Truncating isn't really rounding. It's chopping off additional digits after the specified number of decimal places and ignoring them. So it really has nothing in common with rounding. It does, however, seem to be the type of function for which you meant to ask and LaRetta did a good job discerning that.
-Queue- Posted October 8, 2003 Posted October 8, 2003 Do you mean consistently round up, regardless of the trailing digits? So, 1.27 and 1.21 would both round to 1.3 (instead of 1.3 and 1.2, respectively)? If so, then I would use Truncate( number, X ) + 1/10^X, where X is your number of precision.
LaRetta Posted October 9, 2003 Posted October 9, 2003 Transit said... what I need is to be able to round a figure like 1.2876 down to 1.28 (and) and so needed the rounding down at this point and from what I can gather although it may only display two decimal points it calculates on the full "unrounded" figure Truncate removes the '76' and that 2-decimal figure can't be rounded any lower than 1.28. If you only want to round down, Truncate will do the trick nicely. It will only calculate through the second decimal if you specify the precision of 2. And Round goes both ways, Scott. 1.255 becomes 1.26 and 1.254 becomes 1.25. Truncate would make them both 1.25 because it drops past the second decimal - no rounding. FM provides many wonderful number functions (did I say that Queue?) which will allow fine-tuning of your numbers ... it just depends upon what you want. LaRetta
Recommended Posts
This topic is 7786 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now