if i do the square root of a number and it turn out to not be an integer, what does the prop do, does it round up or down, or does it throw it out and outputs an error message
It floors the number. That is IF you are using the regular, run-of-the-mill integar math. There is an object in the obex that allows you to do float math. I think it's somethink like "Math" or "Float. I'm sure someone who knows the name will guide you to it a little better.
what do you mean floors, i am outputting the number so i really cant use a noninteger value, i just need to know what happens to the result of an equation if its not an integer
I am routinely getting burned by the different ways the Propeller and my add-ons handle different forms of numbers, such an integers and floating math functions (not to mention string values consisting of numbers), so I strongly suggest you look over the float math examples in the OBEX before you decide what you really need to do. It's easy to write code and think you've done the proper thing with your numbers.... until one day something glitches and only then you realize you didn't handle the math the right way.
That's just a matter of the range that your testing did cover
I always do extensive testings with extremly values to be sure that everything works right even with a value beeing a zero
or very tiny or negative, or really huge.
I do this REALLY ALWAYS even if I know in this method the values can NEVER get negative or bigger than 100
I DO test it ALWAYS in general. Testing it this way keeps me away from thinking "oh here it doesn't matter"
In earlier times I had enough cases where I thought "oh here it doesn't matter" and then bug came up later
And by doing this I add code that catches bad values and make the code setting the value to a default-value or
create debug-output that a value was out of expected range
well, since this is for a cnc mill, i dont think that truncatting a value will do much since i cant use a value other than integers, granted there will be small steps in curves, but so small that you wont be able to notice it even when doing a very precise piece. and i wont be selling it to anyone except for my uncle if he wants one,·so it will always be a growing project,
in the case of negative numbers and square roots, i kinda will get a negative number cause the code im using for circular interpolation is y= sqrt(r^2 - (x - h)), where y = y axis movement and·x =·x + 1 until x = 2r·since this equation only does half a circle i would have to also do a negative version counting x down and running the x axis in the opposit direction which would·need to be a negative number to give the second half of the cirlce, but i can just set the direction of y opposite to the first half of the circle
if this doesnt make sense im sorry, it does in my mind
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
That's true only for positive numbers, not for negatives - e.g. floor(-3.2) = -4, not -3
But since we started out talking about square roots, I suppose science_geek is only dealing with positive numbers.
Ross.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
obex.parallax.com/objects/category/6/?page=1
Do as I say, not as I do.
I always do extensive testings with extremly values to be sure that everything works right even with a value beeing a zero
or very tiny or negative, or really huge.
I do this REALLY ALWAYS even if I know in this method the values can NEVER get negative or bigger than 100
I DO test it ALWAYS in general. Testing it this way keeps me away from thinking "oh here it doesn't matter"
In earlier times I had enough cases where I thought "oh here it doesn't matter" and then bug came up later
And by doing this I add code that catches bad values and make the code setting the value to a default-value or
create debug-output that a value was out of expected range
best regards
Stefan
in the case of negative numbers and square roots, i kinda will get a negative number cause the code im using for circular interpolation is y= sqrt(r^2 - (x - h)), where y = y axis movement and·x =·x + 1 until x = 2r·since this equation only does half a circle i would have to also do a negative version counting x down and running the x axis in the opposit direction which would·need to be a negative number to give the second half of the cirlce, but i can just set the direction of y opposite to the first half of the circle
if this doesnt make sense im sorry, it does in my mind