Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
int infinity
#1
i could use an int infinity. i need the number infinity to do some compares. of course, float infinity works fine with > and < comparing to an int. the problem i am having is that the code i'm feeding this to runs the numbers through int() (because it wants to accept floats). then the infinity i give it does not go through int(). if it were to just stay float infinity, or int supported an infinity special value, these could work. any suggestions?

i do not need an int nan.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
I am a beginner too but I found Infinite integer in Python \- Stack Overflow; does that help? The last answer there says I added an implementation of extended integers on PyPI; I think you can install extended-int ยท PyPI for that.
Reply
#3
unfortunately this is intended to be distributed to customers where installing a pypi package is not a option. everything has to be in python 3 itself or my code. i'm thinking of trying to create my own type where itself is the result of any arithmetic involving it except for inf-inf=0 and inf/inf=1. it would be my first type that involves operators. i have already worked around this. i wanted some cleaner code.

years before i started with python, i had design my own language that had some similarity to python and pike. the syntax was more like pike or C. it had an inf that was not int or float or complex. working it through arithmetic would usually get inf as a result. but it was its own type or a special type. type(inf)=inf. nan existed but was specific to the "machine float" that eventually became "ieee float". that's where nan made sense as it was meant to be floating point implementation specific. i never implemented this language.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Star Infinity loop edek121 0 32,933 Jun-05-2022, 12:51 PM
Last Post: edek121
  Importing a CSV loops to infinity in python bluethundr 2 4,555 May-03-2019, 03:28 PM
Last Post: bluethundr
  cannot convert float infinity to integer error despite rounding off floats Afterdarkreader 3 16,865 Dec-15-2017, 02:01 AM
Last Post: micseydel

Forum Jump:

User Panel Messages

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