Forums Register Login

"type int out of range" error on a long variable!

+Pie Number of slices to send: Send
Never mind, I made a stupid blunder since I don't usually use long and never put an L at the end of the i variable.
1
+Pie Number of slices to send: Send
600851475143 is still an int literal. To use it as a long literal, you must append L to it: 600851475143L.
You can officially also use a lowercase l but you should never do that. In some fonts, the difference between l and 1 is not easy to see, so 600851475143l could be seen as both 600851475143L and as 6008514751431. An example:
Without the colouring inside that snippet it would be hard to read the difference between l1 and l2.
2
+Pie Number of slices to send: Send
I would further posit that l1, l2, etc. are not fantastic variable names, for similar reasons.
+Pie Number of slices to send: Send
You have me there. There isn't a problem in the declaration or assignment to those, but using them as arguments, in comparisons or on the right hand side of assignments, can cause confusion. For instance:
With some fonts you may read this as being always true - 11 == 11 after all.
Arch enemy? I mean, I don't like you, but I don't think you qualify as "arch enemy". Here, try this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1117 times.
Similar Threads
Finding a prime factor
Storing numbers as variable type long
Problem with Loops: What have I been doing wrong?
Finding the largest Prime Factor
factors: i hate math
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 16:26:27.