canbula / ieee754 Goto Github PK
View Code? Open in Web Editor NEWPython module which finds the IEEE-754 representation of a floating point number.
Home Page: https://pypi.org/project/ieee754/
License: MIT License
Python module which finds the IEEE-754 representation of a floating point number.
Home Page: https://pypi.org/project/ieee754/
License: MIT License
For 0.5 by using this tool, you can find the accurate IEEE754 Half Precision representation for 0.5 as follows:
But in this repo, we have:
This is inaccurate by 2 bits.
If you choose Quadruple precision, the mantissa portion of the number gets approximated after a certain number of bits.
As an example, the results for Quadruple precision from this converter (https://babbage.cs.qc.cuny.edu/IEEE-754/) are different from the one using the IEEE754 class.
Digging a bit in the methods, the approximation is related to the fact that building the mantissa multiplying by 2 makes the error due to the initial approximation of the floating point number larger and larger, until it affects the result of the mantissa computation.
I read that python and numpy do not handle particularly well high precision real numbers.
I had to employ gmpy2 for my needs, maybe it's worth having a look at it for future modifications to the class.
something is wrong with small numbers lile -0.5687.
IEEE754(-0.5687) = 10111111110010001100101100101001 (= 0xBFC8CB29) while the resultt should be 0xbf119653.
Line 200 in f193095
Using list[str] as a return type requires python3.9 or greater. But I was able to install this on python3.6.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.