Python Forum
Memory assignation problem (maybe?)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Memory assignation problem (maybe?)
#1
...So when I do something like this:

n=int(float(input("enter a positive integer:"))
print(n)
Then I give him the number 113857867458976843 which to be fair is big.

The program prints 113857867458976848!

I just don't understand.
It is... frustrating...
Reply
#2
That's because you don't understand floating point numbers. Read up on them and you'll understand.

In the mean time, don't do that. Why would you ask for an integer, convert it to a floating point number, and then convert it back into an integer?
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
113857867458976843 is between 2**56 and 2**57, but floating point numbers have only 53 significant binary digits, plus an exponent.
Reply
#4
Thank you both!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Memory access speed problem Dupletor 0 1,543 Oct-22-2018, 08:10 PM
Last Post: Dupletor

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020