Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

SRP_Math

At what point does OI start treating a number as zero?0.0000001 (how many zeros need to be in the example)?

I assume this equally affects math functions x / + - and also comparisons like Loops and If statements?

Thanks for any help in understanding this.

Comments

  • Looks like it depends on whether or not your value is quoted. In my tests. '0.00001' (5 decimal places) is equal to 0, but the same number unquoted is not zero. However, unquoted, 0.000001 (6 decimal places) is equal to 0. Thus, 5 decimal places or greater and the EQ operator is going to see them as equal. I played around with more or less significant zeroes, but this doesn't seem to make a difference.

    If you use the SRP_Math "COMPARE" service, then 1E-X is never equal to zero.
  • Interesting. I am using your srp_math function to get around this limitation. I assume it affects all comparisons and all math functions correct?
  • No, it only affects comparison. If you add 0.0 and 0.000001, you'll get 0.000001.
  • Ah ha, interesting. Why does the SRP_Math function have an ADD parameter?
  • SRP_Math does arbitrary precision math, meaning you can do arithmetic on numbers that have hundreds of digits, not just the 15 or so you limited to with BASIC+. For example, this code will break to the debugger:

    A = "0123456789987654321" Ans = A + A

    But this code will perform the addition no problem:

    A = "0123456789987654321" Ans = SRP_Math("ADD", A, A)
  • Got it, I understand. Thanks for the help in understanding.
  • Jim - Kevin will provide the final word and correct me if I am wrong, but I think he misunderstood your question. As far as I know, our arithmetic services (e.g., ADD, SUBTRACT, MULTIPLY, and DIVIDE) will get around the limitation.

    As I recall, OI 10 added extended precision operators to Basic+.
  • Nevermind...Kevin already responded while I was still typing out my response. :)
  • Thanks Don, I understand how all this works now.
Sign In or Register to comment.