Is it possible to use relations in a repeat relation to covert decimal #s to fractions?
I was having issues with some ITOS formulas I found online but I developed some if statements that work well. (sample below) They work well at the part level but I am having issues adapting for the repeat region.
As you've found, relations are pretty terrible for doing things like calculating the fractional equivalent of a decimal number, because they lack basic looping capabilities, You're therefore forced to a rather unweildy clump of nested IF-ENDIF statements. It works, but is really not a nice construct.
Anyway, I don't know what kind of relations examples you've found but here's a chunk from one of my generic bolt models that is trying to calculate the "multiple of 2" fraction (2, 4, 8, 16, 32) that a given decimal number is closest to. Hopefully that's the kind of fraction you are after, and not things like 11/13 and the like
In this snippet, diaNom is the number being looked at, and txtDiaNom is the resultant string containing the fraction.
txtDiaNom = ITOS ( floor ( diaNom * 32 ) ) + "/32" IF MOD ( floor ( diaNom * 32 ), 2 ) < 1 txtDiaNom = ITOS ( floor ( diaNom * 16 ) ) + "/16" IF MOD ( floor ( diaNom * 16 ), 2 ) < 1 txtDiaNom = ITOS ( floor ( diaNom * 8 ) ) + "/8" IF MOD ( floor ( diaNom * 8 ), 2 ) < 1 txtDiaNom = ITOS ( floor ( diaNom * 4 ) ) + "/4" IF MOD ( floor ( diaNom * 4 ), 2 ) < 1 txtDiaNom = ITOS ( floor ( diaNom * 2 ) ) + "/2" ENDIF ENDIF ENDIF ENDIF
Hopefully all the functions (MOD, floor, ITOS) are available in repeat region calculations.
Actually more interested in how to place relations in the repeat region and have the work than the formulas themselves but thank you for the information.