10-27-2023, 11:23 PM
(10-27-2023, 11:04 PM)eoredson Wrote: Maximum int64 seconds in years:
Code: (Select All)Dim y As _Integer64
Dim s As _Integer64
Dim d As _Integer64
s = 86400 ' seconds
d = 365 ' days
Dim t As _Integer64
y = 292277026596 ' years
t = y * s * d
Print "Maxint="; t
Print "Overflow Maxint= "; t * 2
Your number is wrong.
292,277,026,596 <-- Your number of years.
292,471,208,677 <-- Max number of years, stored as seconds, without overflowing.
Code: (Select All)
Screen _NewImage(800, 600, 32)
Dim maxInt64 As _Integer64
maxInt64 = 9223372036854775807
Dim y As _Integer64
Dim s As _Integer64
Dim d As _Integer64
s = 86400 ' seconds
d = 365 ' days
Dim t As _Integer64
y = 292277026596 ' years
t = y * s * d
Print "Maxint="; t
Print "Overflow Maxint= "; t * 2
Print
Print "Correct Values"
Print Int(maxInt64 / (86400&& * 365&&)) '60 seconds in 60 minutes in 24 hours in 365 days
Print maxInt64; " <== Max INT64"
Print 292471208677&& * 86400&& * 365&&; " <== Max number of years in seconds, you can store in an INT64"
This is a simple case of division. Why's it so hard to get the correct answer here? Am I missing something?