Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : MM Basic Exponentiation
Author | Message | ||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5905 |
I just came across an interesting discussion on the PureBasic forum. Do you treat 4^3^2 as (4^3)^2 (left to right) or 4^(3^2) (right to left). PRINT "4^3^2 = ";4^3^2
PRINT "(4^3)^2 = ";(4^3)^2 PRINT "4^(3^2) = ";4^(3^2) Microsoft seems to work left to right and as MM Basic is based on GW Basic, it also uses left to right. This is stated in the manual so there should be no confusion. It appears that many programming languages work right to left for 'power' Wikipedia says the exponential operator is right associative http://en.wikipedia.org/wiki/Operator_associativity Something to watch out for when translating programs and a good reason for lots of brackets. Jim VK7JH MMedit MMBasic Help |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3659 |
Interesting.... though I don't think I've ever written a double exponentiation in any language! John |
||||
Dylan Regular Member Joined: 17/06/2013 Location: NetherlandsPosts: 81 |
There are two reasons to. 1) Computer Science 2^(2^5) = 2^32 = maximum memory for a 32-bit OS, for example. 2) Physical sciences (2^t)^(1/3) = volume of something doubling every t time units. Just don't look up http://en.wikipedia.org/wiki/Tetration and all will be well. |
||||
BobD Guru Joined: 07/12/2011 Location: AustraliaPosts: 935 |
You mentioned it, I couldn't resist, I read the lot, and I am now more deranged than ever. |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3659 |
For sure I've quite often used 2^32 one way or another, just never written it using a (to me pointless) double exponentiation. John |
||||
Print this page |