Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Gmpy2 Newbie Working on Precision
Post: RE: Gmpy2 Newbie Working on Precision

(Jan-22-2024, 03:44 AM)charlesrkiss Wrote: I went to a random calculator website: https://math.tools/calculator/trignometry/asin From there I found similar results and created a table of the valu...
casevh General Coding Help 5 487 Jan-23-2024, 06:51 AM
    Thread: Precision with Decimal Type
Post: RE: Precision with Decimal Type

(Jan-17-2024, 10:45 PM)charlesrkiss Wrote: Hello Perfringo, You can see in the second balloon above (repeated below) how theta is close to a ninety-digit number that I input to math.cos, but my int...
casevh General Coding Help 9 634 Jan-18-2024, 05:55 AM
    Thread: Looking for clarification related to performance
Post: RE: Looking for clarification related to performan...

It is difficult to provide a complete answer without understanding the context - both of the person making the statement "function calls are slow" and what your program does. So let's look at adding t...
casevh General Coding Help 5 1,996 Apr-03-2022, 03:53 AM
    Thread: numpy.dot() result different with classic computation for large-size arrays
Post: RE: numpy.dot() result different with classic comp...

The quick answer is that numpy.dot calculates the using the type in the construction of arrary.array. "q" represents a 64-bit signed integer which overflows at 2**63-1. This eventually overflows and t...
casevh General Coding Help 5 1,829 Jan-25-2022, 08:09 AM
    Thread: efficiency of CPython expression comppilation
Post: RE: efficiency of CPython expression comppilation

Python does perform constant expression optimizations. The dis (short for disassemble) module can show it in action. >>> def f(x): ... return x/(7*24*60*60) ... >>> import dis &g...
casevh News and Discussions 1 1,249 Jan-09-2022, 06:03 AM
    Thread: f-strings round float down too much
Post: RE: f-strings round float down too much

You are correct. My memory is a bit hazy. Looking at this again, I'm not exactly sure what is the bug....
casevh News and Discussions 5 2,515 Dec-29-2021, 04:13 PM
    Thread: f-strings round float down too much
Post: RE: f-strings round float down too much

There are at least two different strategies for representing 64-bit IEEE floating point values as a decimal string that round-trip. In other words, they guarantee that x == float(str(x)). One choice i...
casevh News and Discussions 5 2,515 Dec-29-2021, 07:25 AM
    Thread: unexpected decimal.InvalidOperation
Post: RE: unexpected decimal.InvalidOperation

The behavior you are seeing is part of IEEE-754 standard. The easiest chart I found is in the "Special Operations" section of https://steve.hollasch.net/cgindex/codin...float.html. The specification...
casevh News and Discussions 2 1,845 Dec-25-2021, 07:53 AM
    Thread: smallest float that can increment a given value
Post: RE: smallest float that can increment a given valu...

(Dec-11-2021, 06:35 PM)snippsat Wrote: (Dec-11-2021, 06:05 PM)Skaperen Wrote: what would you pick for a name?There is hint in his post,as he already has chosen names in gmpy2. Also hi is the autho...
casevh News and Discussions 7 2,770 Dec-11-2021, 10:22 PM
    Thread: smallest float that can increment a given value
Post: RE: smallest float that can increment a given valu...

sudo apt install libmpc-devThat will install the GMP, MPFR, and MPC libraries. You can then compile from source. Or if you are using a version of Python distributed by Ubuntu, you can use sudo apt i...
casevh News and Discussions 7 2,770 Dec-11-2021, 10:08 PM
    Thread: smallest float that can increment a given value
Post: RE: smallest float that can increment a given valu...

Not exactly, but the math module provides the function nextafter(x,y) that returns the next floating-point value after x towards y. >>> math.nextafter(12,0) # The next float towards 0. 11.99...
casevh News and Discussions 7 2,770 Dec-11-2021, 05:32 AM
    Thread: shouldn't this raise an exception?
Post: RE: shouldn't this raise an exception?

>>> from decimal import * >>> getcontext() Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999, capitals=1, clamp=0, flags=[], traps=[InvalidOperation, DivisionByZer...
casevh News and Discussions 3 2,752 Dec-08-2021, 05:01 AM
    Thread: who is Barry?
Post: RE: who is Barry?

Barry was one of the early users of Python and he is still involved with Python. You might want to look at PEP 0401 ( https://www.python.org/dev/peps/pep-0401/ ).
casevh Bar 7 2,599 Nov-15-2021, 11:01 PM
    Thread: Calculate the Euler Number with more decimal places
Post: RE: Calculate the Euler Number with more decimal p...

(Oct-22-2021, 12:17 AM)Pedroski55 Wrote: Thanks for your replies! I use Ubuntu 20.04 I only tried to install gmpy2 using pip. I'm not very clear about installing from source, I never do that, but...
casevh General Coding Help 10 4,392 Oct-31-2021, 03:46 AM
    Thread: Pass by object reference when does it behave like pass by value or reference?
Post: RE: Pass by object reference when does it behave l...

The Python interpreter only comprehends pass by object reference. Whether a new object is returned (kind of, but not really, like pass by value) or an existing object is modified (kind of, but not rea...
casevh General Coding Help 2 2,513 Sep-07-2020, 06:05 AM
    Thread: system-wide unique incrementing string or number
Post: RE: system-wide unique incrementing string or numb...

I would look at time.monotonic() and some related functions. They are designed to monotonically increase even if NTP is used to adjust the time. I don't know how they behave after a system reboot if t...
casevh News and Discussions 11 4,010 Jul-07-2020, 07:05 PM
    Thread: time complexity of int
Post: RE: time complexity of int

Python does use an improved algorithm for squaring large numbers. The improvement just decreases the constant so the time complexity doesn't change. The improvement is measurable. a is 1232 bits long...
casevh News and Discussions 6 2,625 Jul-05-2020, 03:03 PM
    Thread: time complexity of int
Post: RE: time complexity of int

Yes, comparison is also O(n).
casevh News and Discussions 6 2,625 Jul-05-2020, 05:06 AM
    Thread: time complexity of int
Post: RE: time complexity of int

Assume n is length of the number in bits and let's use ^ for exponentiation. Addition and subtraction are O(n). Multiplication uses the Karatsuba algorithm that is O(n^1.585) instead of the classica...
casevh News and Discussions 6 2,625 Jul-04-2020, 08:28 PM
    Thread: PyArray_SimpleNew gives "ValueError: array is too big; for 3-cubed array
Post: RE: PyArray_SimpleNew gives "ValueError: array is ...

Have you tried declaring dims[] as "npy_intp dims[3];"? casevh
casevh General Coding Help 1 3,023 Nov-30-2019, 05:02 AM

User Panel Messages

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