View Full Version : Whole Integer values.
archjake
2006-06-27, 03:26 PM
Does anyone know of a formula to round numerical values to a whole integer?
Revit can set parameter values to an integer, but when it is used in calculating it will calculate with the decimal value.
I'm getting rounding errors in my calculations because of the decimal / rounding.
Thanks,
LRaiz
2006-06-27, 04:02 PM
Assigning a numeric value with fractions to an integer parameter will do rounding. You may need to experiment and see if Revit does it by truly rounding (finding the closest integer) or by truncating (discarding fractional part). If Revit truncates and you want rounding then just add 0.5 to your formula.
archjake
2006-06-27, 04:49 PM
You gave me an idea and it worked.
I have the square footage of a room. lets say 1509 s.f.
Then I need to find the estimated no. of people. Lets say 50 people per 1000 s.f.
so .05 * 1509 = 75.45
Usually I would let Revit round this 75.45 to 75. Then I would multiply this by the requirement.
This was an outside air calculation, so I needed 20 cfm per occupant.
Revit would display 75, but would use 75.45 to calculate the required OSA. This is where my rounding error would occur. 75.45 * 20 = 1509. Where my table was reading 75 * 20 = 1500.
I'm 9 cfm over.
After reading Lraiz's reply, I fixed my problem by adding a parameter that is an integer that equals the parameter 75.45. ie: "Integer No of People" = "No Of People".
so "Integer No of People" is a set 75 occupants for my calculation of 75 * 20 = 1500
If I wanted that value to equal 76 people because I had part of a person I could add the .49 to always round up.
Thanks.
LRaiz
2006-06-27, 07:01 PM
I think it is even better to define No_Of_People parameter to be of type an integer (not number) from the very beginning. Then you can use the formula
No_Of_People = Area * 0.05 / (1sf) + 0.5
There are two important things to note in this formula.
1) I multiply by 0.05 and divide by 1 square foot to get fractional number of people. Users often forget about the necessity to divide by square foot. Then Revit complains about inconsistent units and users are tempted to look for crazy workarounds. Since Revit does not know the units of measurements for your people-per-area coefficient (it could be per square feet or per square meters) then you should not forget to specify it explicitly.
2) Revit already round to the nearest integer. You need to add 0.5 (not 0.49) if you want to always rounding up to the bigger integer. Otherwise values like 75.009 will result in 75 not 76.
archjake
2006-06-27, 07:52 PM
I think it is even better to define No_Of_People parameter to be of type an integer (not number) from the very beginning.
I agree, that would have been ideal, but I couldn't just change an existing parameter that was intermingled in multiple schedules and a key schedule.
Is there a way to change a parameter after it is created without deleting it out and creating a new one? If so, I can't find it. And if so, does it matter if it is a project parameter vs shared?
You are correct about adding a 0.5 to always round up.
In my calculation I don't have to round up until 0.5 or greater.
Thanks for the help
LRaiz
2006-06-27, 08:10 PM
Currently there is no way to change the type of already created parameter. You can only make a new one and gradually edit existing schedules replacing old parameter with a new one in formulas. Then after all schedules are edited delete the old parameter.
As far as project vs shared parameters as a rule of thumb use project parameters is you don't need them to appear in tags and don't need to use them in families. Shared parameters are useful if you need to share them between files (like using the same parameter in tag and schedule). However this question is mute because formulas are currently limited to Calculated Values and can't be applied to regular parameters.
lcamara
2008-05-07, 01:20 AM
Actually, you would want to use 0.49 (or 0.499999 as I do) so that a 1.0 won't get rounded to a 2 (unless you want that behavior).
Now, if the similar problem occurs, where the number end up with 75.6, and I want it to go to 75, and/or if the number has any fraction i want it to round down. How do i do that?
Thanks,
Tony
lcamara
2008-05-15, 11:13 PM
To round down, subtract 0.5 first (not 0.499999).
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.