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

srp_math is great.
I hate it when OI puts values in scientific notation.
But we would expect an error when srp_math operations are performed on delimited values.
a = 123:@vm:456
We expect an error with: result = srp_math('ADD',a,1)

What we can do : result = srp_math('ADD',a*1,1)
But then we land in the debugger

Another thing is that the result is formatted with the provided decimal places.
srp_math('ADD',1,1,2) returns "2.00" we would rather see "2" as the result.
srp_math('ADD',1,1,2)*1 returns "2" for us.

Regards Ed

Comments

  • The SRP_Math error handling system focuses on logical arithmetic errors, not parsing errors. It assumes you'll do the work of validating that the input represents numerical data. Otherwise, SRP_Math will attempt to parse anything you give it, and if it can't parse it at all, it will assume 0.

    In your second example, you are specifically setting the decimal places to 2, so 2.00 is expected. If you set that parameter to 0, you'll guarantee the result to be rounded to the integer. If you omit the third parameter, the result is in the same significant digits as the inputs, which in your example, would also return 2.
Sign In or Register to comment.