How to get the Smallest number RIGHT BEFORE infinity?

Do not ask my why i need it but…

How to get the number before infinity?

Lets say that number is x. i want x + 1 to be infinite BUT x not. like

print(x) --> SomeRandomNumber
print(x+1) --> inf

Methods i tried

  • Infinity - 1
    (2^1024)-1 → Prints inf even without adding +1

  • Some huge numbers multiplied and added
    (2^1023.9999999999999)+(10^295.151)+(10^294) → huge but that +1 ~= inf

Early ty for helping :>

The amount of numbers between 0 and infinity is infinity, it’s mathematically impossible to get the smallest number right before infinity because the numbers go on forever

1 Like

There is no number before infinity . It is possible to represent infinity minus one as a mathematical expression, but it does not actually equal anything or have any real mathematical value.

1 Like

Infinity is a concept, not a number, it is used to say that there is an endless amount of something.

Here, In Code, I guess you can say 2^1024 = math.huge = inf, which 2^1024 is where numbers become “infinity”, so about anything below 2^1024 wont be infinity, but as far as im concerned, 1.7976931348622742e+308 would be pretty close (its the closest I could get), which is a very big number.

But either way, it would be sort of difficult considering how many numbers are accounted for before reaching that number.

2 Likes

The maximum value you’ll be able to use with built-in numbers is the 64-bit float limit:
2^1023 * (1 + (1 - 2^-52)) which is 1.7976931348623157e+308.

The thing is though is that when you add 1 to a float that big, the operation does nothing due to the precision of the numbers. You only get about 15/16 digits of precision before this happens. E.g.

> print( 1e16 == 1e16 + 1 )
true
> print( 1e15 == 1e15 + 1 )
false

You can read more about it on wikipedia Double-precision floating-point format - Wikipedia

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.