Right so I made a program that's a calculator. After getting help for something else I went on my day but after troubleshooting it for a bit I found that I'd get an answer that I don't think I should get. Usually 46340*50000 is 2,317,000,000 and not a negative number (Like what's returned here), correct? I think it's because the long data type (Which is used here) can't store it though, would I be right? Or is it due to something else
#Calculator Troubleshooting
7 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @little hemlock! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
When I casted the variables (number_one/two, which are integers) to long for that in particular I was able to get the correct answer. Is there a tidier way of doing that conversion then, so that it's applicable prior to the cases (So I don't have to repeat it)
you can read long value from input. scan.nextLong() and assign to long variables
Oh, in the end I just changed the variables (number_one, number_two) to long data types coz there's really no reason not to right?
Since I don't think there's a structural difference between them besides how much they can hold and I'll be using bigger numbers