hop-frog
05-10-2004, 06:40 PM
I am writing a script together in Python and Bash, that generates hundreds of sets of (x,y,z) coordinates, which are passed to a 3D modeller.
The modeller does not understand decimals or fractions. Scale doesn't matter, but everything must be proportional. For this reason, I am able to multiply the numbers by 10, 100, 1,000, etc. to get rid of decimals.
For example (10.125, 3.25, 0) multiplied by 1000 becomes (10125, 3250, 0) and the decimals are gone. If I used 1000, to mulitply 10.0125, I would have be delete the remaining decimal. In some cases, this decimal is important, for example, if the range of generated numbers fell between 10 and 10.05.
Whether I multiply by 10, 100, 1,000, or 1,000,000,000 would depend of the number set. This number for what to mulitply by is what I am trying to arrive at.
1) Is there a process by which Bash or Python read a number and print out the number of significant digits, or decimal places so that I can average this?
2) How can I make the script sort out which numbers are rational and which are rational?
The modeller does not understand decimals or fractions. Scale doesn't matter, but everything must be proportional. For this reason, I am able to multiply the numbers by 10, 100, 1,000, etc. to get rid of decimals.
For example (10.125, 3.25, 0) multiplied by 1000 becomes (10125, 3250, 0) and the decimals are gone. If I used 1000, to mulitply 10.0125, I would have be delete the remaining decimal. In some cases, this decimal is important, for example, if the range of generated numbers fell between 10 and 10.05.
Whether I multiply by 10, 100, 1,000, or 1,000,000,000 would depend of the number set. This number for what to mulitply by is what I am trying to arrive at.
1) Is there a process by which Bash or Python read a number and print out the number of significant digits, or decimal places so that I can average this?
2) How can I make the script sort out which numbers are rational and which are rational?