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.
round( ) function
tim_ashby
Member Posts: 3 ✭✭
Is it possible to specify the number of decimal places that the round( ) function rounds to? The standard Excel format of round(number, dp) doesn't seem to work. Alternatively, is there a workaround?. Thanks!
0
Best Answer
-
round(value * 100) / 100 should do the trick (to 2 dp)Senior Director, Technical Services, EMEA2
Answers
-
round(value * 100) / 100 should do the trick (to 2 dp)Senior Director, Technical Services, EMEA2
-
round() as now a value and a multiple.0
-
@patrick_farley
round(value, .01) is probably what you are looking for rather than round(value, 2):
https://cad.onshape.com/FsDoc/library.html#round--
Jake Rosenfeld - Modeling Team0 -
You'll notice also in that documentation that value and multiple can also both be valueWithUnits, and the result will come out as a plain number (whose "unit" corresponds to the "multiple")Jake Rosenfeld - Modeling Team0
-
I'm trying to use the solution above, but I keep getting errors (Function Round with 2 argument(s) not found). Any idea what can go wrong here?
Part of my codevar es = definition["segment" ~ i] / millimeter;partNumber ~= toString(round(es, .01));Creative Technician Mechatronics | Freelance Engineer
www.leontulling.nl0 -
@leon_tulling You're likely on a very old version of the FS standard library. The two-argument function was introduced around six years ago.
0 -
@leon_tulling roundToPrecision() is the new way to do this. See here https://cad.onshape.com/FsDoc/library.html
1






