Isolate the number after the decimal point?

If we have an answer to an equation and that is not a round number how do we isolate the digits after the decimal point.?

You could use a GHPython component and this function:

import math
decimalPart,integerPart = math.modf(yourNumber)

Thank you @AndersDeleuran
I’m unfamiliar with how the GHPython component works, could you please elaborate … see attached
HOW DO WE (3.0 KB)

You have to rename your input math to yourNumber for Anders’ code to work. It’s also a bad idea to call it math, since that’s already the name of the Python math module that you import.
Additionally, you need to remove the output yourNumber. It’s unnecessary! And rename output a to decimalPart.

But that will give you 0.47

I would do it like this:

decimalPart = int(str(yourNumber).split(".")[-1])  # 47 

Alternatively, you could do this too:

HOW DO WE (7.6 KB)

You can also do this with standard Grasshopper components, by subtracting the Floor output of the Round component from your value with decimals.

1 Like

Or you can use Deconstruct Number from the Pufferfish plug-in

There you go: (2.9 KB)

Edit: Ah, you don’t actually want the decimals as a float, but just the string. In which case, you could slice the input string at "." like so: (5.3 KB)

1 Like