Good afternoon everyone,
i have a list of numbers (Level.Elevation) that i want to “encapsulate” between parenthesis ()
When the numbers gets out of Math.Round i do have 2 decimals.
t2 =Math.Round(t1, 2);
But as soon as i try to encapsulate it into () i end up with 6 decimals
t2 = “(” + Math.Round(t1, 2) + “)”;
Any idea how to keep the 2 decimals?
Im using this for now, still would like to understand the logic
I don’t know about the logic of it but when you turn a number into string it gets 6 decimals. Have a look at this thread.
That’s what i’m doing but still interested in understanding the logic
I guess a string is always 6 decimals
That might have something to do with how doubles/floats are converted to string in c#
A solution would be to trim out the extra zeros after converted, considering that you have already rounded to two decimals (and the other 4 will be zeros anyway).
use a Python node:
from Autodesk.DesignScript.Geometry import *
dataEnteringNode = IN
OUT = “(” + str(round(IN, 2)) + “)”
Do you know about this Node?
That is a custom node that does not work. Maybe it can’t handle lists input.
Have a look here:
Ended up being a custom node in Data-Shapes
hi guys, what about dropping all decimals after the point?
other way than maybe converting to String and cutting it before the point “.”?
I keep searching the internet but to no avail.
Roundinng rounds stuff, i want to discard info.
If i have 2.6 and 2.3 one will be rounded to 3 and other one to 2, right?
You can round down though. Use
Can you give an example of a number you have, and what you want it to be? Like do you just want 2.6 to be 2 and 3.4 to be 3? Is something else?
I think he is trying say, above 2.5
Will consider 3 and below 2.5
Will consider 2.
As @Nick_Boyts replied math.floor and math round will do the same.
Hello! Yes! This is what i was looking for. A bit silly.
You might also want to look at bankers rounding / round-to-even with the following overload:
Math.Round(number, 2, MidpointRounding.ToEven);