Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Potencies high potencies
#5
Quote:@LEM -  I think your issue is dimensioning the "sum" variables as long (or unsigned long).  The result of 5^16 is much larger than can be represented by a long, I think.  Try without dimensioning as unsigned long.
Thanks, that was it! And a typo in sum 2 was the reason for the wrong result. Now it works.

Code: (Select All)

'Matheuebung Potenzen hoch Potenzen - 7./8. Okt. 2024

Option _Explicit

Dim As Integer a, b, c
Dim As _Integer64 sum, sum2, sum3

Locate 2, 3
Print "Berechnet ((a ^ b) ^ c)"
Locate 3, 3
Print "======================="
'Beispiel: ((5^4)^4) = 5^16
'MS-Rechner: 152.587.890.625 -- Hier: 2.264.035.265

Locate 5, 3
Input "a: ", a
Locate 6, 3
Input "b: ", b
Locate 7, 3
Input "c: ", c

sum = ((a ^ b) ^ c)
Locate 9, 3
Print Using "Summe 1: ###,############"; sum

sum2 = a ^ (c * b)
Locate 11, 3
Print Using "Summe 2: ###,############"; sum2

sum3 = a ^ 16
Locate 13, 3
Print Using "Summe 3: ###,############"; sum3

End

[Image: Matheuebung-Potenzen-Korr.jpg]
Reply


Messages In This Thread
Potencies high potencies - by Kernelpanic - 10-07-2024, 09:21 PM
RE: Potencies high potencies - by bplus - 10-07-2024, 09:51 PM
RE: Potencies high potencies - by Kernelpanic - 10-07-2024, 10:20 PM
RE: Potencies high potencies - by LEM - 10-07-2024, 10:38 PM
RE: Potencies high potencies - by Kernelpanic - 10-08-2024, 01:34 PM



Users browsing this thread: 1 Guest(s)