 # Numbers with Decimals

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?

Thanks

Im using this for now, still would like to understand the logic Hi Daniel
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#
https://msdn.microsoft.com/en-us/library/kfsatb94(v=vs.110).aspx

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). 3 Likes

use a Python node:

import clr
from Autodesk.DesignScript.Geometry import *
dataEnteringNode = IN
OUT = “(” + str(round(IN, 2)) + “)”

2 Likes

Hello everyone,