Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
strange behaviour of raise to power
#2
Sort of.
ZX Basic uses the ROM FP-Calc. Unfortunately, (-3)^2 (or any other negative integer) gives Invalid Argument.
Indeed, you should get this error when returning to BASIC.
This is a limitation of the ROM FP-Calc which uses Logarithms to compute the power of a number. Hence powers of negative numbers cannot be computed. However, you can do x * x in this case.
I'm looking for an alternative to this, but for floats it's not easy: x^y for x < 0 (negative numbers) is tricky if y is float. For example (-3)^0.5 is the same as SQR(-3) which is imaginary (and will return also Invalid Argument).
Maybe there is an algorithm using the ROM FP to compute this?
---
Boriel
Reply


Messages In This Thread
strange behaviour of raise to power - by jjluke65 - 01-05-2025, 12:53 PM
RE: strange behaviour of raise to power - by boriel - 01-05-2025, 01:33 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)