Python Forum
fraction module: can you stop the reducing?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
fraction module: can you stop the reducing?
#2
No, not really.

There's an internal _normalize flag that can be set, allowing the creation of non-normalized fractions (and probably leading to much undefined behavior).  

>>> frac(3, 6, _normalize=False)
Fraction(3, 6)
But it wouldn't do anything for the results of calculations.  Part of the use of the module is to allow equal fractions to be found equal, and that's done through normalization.  So it looks to be a core part that can't be disabled.

>>> frac(1,2) == frac(3,6, _normalize=False)
False
Reply


Messages In This Thread
RE: fraction module: can you stop the reducing? - by bowlofred - Oct-10-2020, 06:10 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  method to remove zero digits from fraction in decimal Skaperen 17 2,862 Oct-23-2022, 04:02 AM
Last Post: Skaperen
  Reducing runtime memory usage in Cpython interpreter david_the_graower 2 2,262 Oct-18-2021, 09:56 PM
Last Post: david_the_graower
  Reducing JSON character count in Python for a Twitter Bot johnmitchell85 2 58,170 Apr-28-2021, 06:08 PM
Last Post: johnmitchell85
  Fraction Calculation with Limitations TINMAN01 13 5,486 Dec-22-2020, 04:45 AM
Last Post: bowlofred
  Need help reducing some code around a subprocess anistorian 4 2,989 Jun-12-2019, 03:32 PM
Last Post: snippsat
  output list reducing each time through loop 3Pinter 6 3,563 Mar-19-2019, 01:31 PM
Last Post: perfringo
  whole number and fraction Skaperen 11 5,649 Mar-17-2019, 11:33 PM
Last Post: Skaperen
  Stop execution of a module catosp 4 3,546 Sep-11-2018, 06:55 PM
Last Post: catosp
  Reducing code length xavier992 4 4,482 Jul-22-2017, 12:45 AM
Last Post: xavier992

Forum Jump:

User Panel Messages

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