Get decimals with dividing

Dear Dynamo Specialists,

I would like to get the 1 decimal of the number 2.5 (result 10/4)

What do I have to do?

Thanks in advance!

Hi @rlandkroon,

you need to make the 4 → 4.0

you can also do:

x = float(10)
y = float(4)
OUT = x/y
2 Likes

i did it more complicaded:


import math

hvl = (10/4.0)

OUT = '{:0<4}'.format(hvl)

also intresting:

import math

hvl = math.ceil(10.0/4)

OUT = '{:0<4}'.format(hvl)

grafik

Keep in mind that the result of this code is NOT a number (integer or double), but a string
000246
This might cause trouble later on if people expect a number

2 Likes