Python rounding float number

Hello,
Why does python rounding float number?


image

@denisyukj ,

i solved it this way

3 Likes

What version of Dynamo and Python are you running? It works fine for me in CP3. I think IP2 takes single numbers as integers by default so the 3/2 term is being set as an integer and rounded before being converted to a float. You can get around this by setting either 3 or 2 as a float first, as @Draxl_Andreas pointed out.

@Nick_Boyts
image

image

@Draxl_Andreas
Thank you, I will try to implement your idea.

Like that :joy:

@denisyukj ,

it looks horrible - perfect :wink:

Lol that works!

As an FYI, number types work like significant figures: the output type will always match the most accurate input type. If all values are integers you’ll get an integer output. If at least one value is a float/double you’ll get a double output.

So @Draxl_Andreas’s solution doesn’t even require you to convert the value to a double. The output is already a double because a double is used in the calculation.
image

3 Likes

Thank you!

1 Like