Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
ceil() misbehaving

I'm trying to round up a value but:
1. ceil(1) or ceil(1,1) return 1 and roundToPrecision(2,0) returns 2 as expected.
2. ceil((2405mm-1200mm)/(1200mm+5mm),1) returns 2 ??
3. roundToPrecision((2405mm+5mm)/(1200mm+5mm),0) returns 3 ??
Please tell me what I am doing wrong here!
1. ceil(1) or ceil(1,1) return 1 and roundToPrecision(2,0) returns 2 as expected.
2. ceil((2405mm-1200mm)/(1200mm+5mm),1) returns 2 ??
3. roundToPrecision((2405mm+5mm)/(1200mm+5mm),0) returns 3 ??
Please tell me what I am doing wrong here!
0
Best Answers
-
_anton Member, Onshape Employees Posts: 118
#2 is because ((2405mm-1200mm)/(1200mm+5mm) is equal to slightly more than 1 because of floating-point math, and the ceil(..., 1) rounds it up to the next multiple of 1, which is 2.
For #3, I'm getting 2.1 -
NeilCooke Moderator, Onshape Employees Posts: 4,682
Yes, everything is stored in meters.Director, Technical Services, EMEA2
Answers
For #3, I'm getting 2.
According to this link https://www.h-schmidt.net/FloatConverter/IEEE754.html I can see that I shouldn't have errors unless rather then FS units storing values with units as milimeters it actually stores them as meters. In other words 1200mm in the value with units type map is stored as 1.200 and units is meter.
This seems to be consistant as I've tested it with a couple FS scripts: