Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8822331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:04:51+00:00 2026-06-14T06:04:51+00:00

It was my understanding that python could handle integers of arbitrary length. It handles

  • 0

It was my understanding that python could handle integers of arbitrary length.
It handles addition and multiplication very well, but seems to fall apart with division.

>>> from decimal import Decimal, getcontext
>>> getcontext().prec=2**5 
>>> ORIG_NUM=476939688738611836995535477357070857939902076027788232031989775824606225595773435668861833
>>> print(Decimal(ORIG_NUM)/7)
6.8134241248373119570790782479582E+88
>>> print("%.6f" % (Decimal(ORIG_NUM)/7))
68134241248373123068520468160885027682039120236463560535175757714209021725053511199096832.000000

I do not want the e notation hence the getcontext().prec attempts. Also, confused by the %f dropping the decimal?

>>> getcontext().prec=2**7
>>>QUOTIENT= (Decimal(476939688738611836995535477357070857939902076027788232031989775824606225595773435668861833)/7)

>>>print(QUOTIENT)
68134241248373119570790782479581551134271725146826890290284253689229460799396205095551690.428571428571428571428571428571428571429
>>>QUOTIENT*7
4.7693968873861185e+89
>>> Decimal(QUOTIENT)*7
Decimal('476939688738611861479643277126195193774273841655244923746230303999463152075374578393677824')
>>> print(Decimal(QUOTIENT)*7)
476939688738611861479643277126195193774273841655244923746230303999463152075374578393677824
>>> print(Decimal(QUOTIENT)*7)==ORIG_NUM
476939688738611861479643277126195193774273841655244923746230303999463152075374578393677824
False

Second issue is the numbers do not match up.

Any information on the subject?

Hope that’s better…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:04:53+00:00Added an answer on June 14, 2026 at 6:04 am
    1. print(Decimal(QUOTIENT)*7)==ORIG_NUM fails because the print function returns None.
    2. If you want exact division, use the Fraction class.

      >>> from fractions import Fraction
      >>> x = 476939688738611836995535477357070857939902076027788232031989775824606225595773435668861833
      >>> f = Fraction(x, 7)
      >>> print(f)
      476939688738611836995535477357070857939902076027788232031989775824606225595773435668861833/7
      >>> f * 7 == x
      True
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Understanding Python decorators Could you please give a short code example that
It is my understanding that one can handle events through Swing by adding a
I am asking this because I use Python, but it could apply to other
My understanding was that Python strings are immutable. I tried the following code: a
My understanding is that mod_python loads the python process into apache, avoiding the overhead
Understanding that I should probably just dig into the source to come up with
It is my understanding that two unequal objects can have the same hashcode. How
It's my understanding that in Spring, all objects are treated by default as singletons.
It's my understanding that all three of these lines below should return an ARRAY
It is my understanding that a texture atlas is basically a single texture that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.