Skip to content

🦘 RadixHopper is a Python library for efficient radix-based number system conversions, specializing in cyclic fractions handling, for bases 2 through aleph null!

License

Notifications You must be signed in to change notification settings

aarmn/radixhopper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

✨ RadixHopper ✨

PyPI - Version PyPI - Python Version


🌟 Hop between number bases with ease! 🌟

RadixHopper is a python library and terminal utility for flexible numerical radix (a.k.a base) conversions, specializing in cyclic fractions handling, for arbitrary bases with arbitrary digits, with sane default and crazy levels of customization.

✨ Features

  • πŸ”’ Convert numbers between radices 2 to 36 out-of-the-box, and more with custom digits!
  • πŸ§‘β€πŸ”¬ Support for scientific notation
  • πŸ¦… Arbitrary precision operations, by leveraging fractions
  • πŸ–₯️ Support for `0x`, `0o` and `0b` format
  • πŸ”„ Handle cyclic fractions with grace
  • πŸš€ Fast evaluations with conversion buffering
  • πŸ““ Jupyter notebook support
  • 🎨 Intuitive CLI interface
  • 🌈 And a lot more...
RadixHopper Logo

🌠 Installation

Sprinkle some magic into your Python environment:

pip install radixhopper

🎭 Usage

As a library

from radixhopper import RadixNumber

# Create a RadixNumber instance from a string in base 10
num = RadixNumber("3.14", base=10)

# Convert it to base 2
result = num.to(base=2)

# Print the representation in base 2
print(f"{result!r}") # or simply `>>> result` or print(repr(result))
# >>> RadixNumber(number=11.0[01000111101011100001], representation_base=2, digits=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ, case_sensitive=False, fraction=(157/50))

# Access the string representation directly
print(result)
# >>> 11.0[01000111101011100001]

# Perform operations
num2 = RadixNumber("1.1", base=2) # Represents 1.5 in base 10
sum_result = num + num2 # Operations default to Fraction representation
print(sum_result) # >>> 100.[10100011110101110000]
print(sum_result.to(base=10)) # >>> 4.64

CLI

radixhopper 3.14 --from 10 --to 2

or simply

radixhopper 3.14 10 2

🌟 Contributing

We welcome contributions! Please check our Issues page for open tasks or suggest new features.

πŸ“œ License

radixhopper is distributed under the terms of the MIT license.

🌠 Star Gazing

   *  .  . *       *    .        .        .   *    ..
  .    *        .   ✨    .      .     *   .         *
    *.   *    .    .    *    .    *   .    .   *
  .   .     *     .   ✨     .        .       .     .
    .    *.      .     .    *    .    *   .    .  *
  *   .    .    .    .      .      .         .    .
    .        .    . ✨      *   .    .   *     *
  .    *     *     .     .    *    .    *   .    .
    .    .        .           .      .        .
  *     .    . *    .     *     .        .     *

Happy hopping! ✨🐰✨

About

🦘 RadixHopper is a Python library for efficient radix-based number system conversions, specializing in cyclic fractions handling, for bases 2 through aleph null!

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published