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 ISOLATE.gh (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 ISOLATE-rev.gh (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.
There you go:
230323_MathModF_00.gh (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:
230323_MathModF_01.gh (5.3 KB)