Combined multiply/divide operator

Vadim

New Member
May I suggest considering addition of one more operator or function to PICAXE BASIC? Like one used in FORTH, it should perform as Z=MUL_DIV(A,B,C) and calculate first a 32-bit production of two 16-bit arguments A and B, then divide it by third 16-bit argument C and return a 16-bit value. This would greatly increase the accuracy one can get using only 16-bit integers.
 

hippy

Technical Support
Staff member
That should be possible to do using existing PICAXE operators ...

- msw = a ** b
- lsw = a * b

That gives a 32-bit product in 'msw:lsw', the question then comes as to how to divide that by 'c'. That could be done by repeated subtraction or by using a more clever and faster alagorithm.

Admittedly not as elegant as having an in-built function. If I can create a PICAXE algorithm I'll post it.
 
Top