jaypha / fixed Goto Github PK
View Code? Open in Web Editor NEWFixed point type for D.
License: Boost Software License 1.0
Fixed point type for D.
License: Boost Software License 1.0
DUB does nothing with your library because the target type is sourceLibrary, wouldn't it make more sense to change it to library ?
if you add alias toString = asString
to the Fixed structure this would allow pretty printing and automating formating of the value (write, writeln, format, std.conv.to, etc.).
Any reason explaining why you don't use it ?
Now does the speed of this compare to floats or plain longs? Have you done any benchmarking?
First, the whole reason to have a fixed-point system is to avoid the vagaries of floating point. I do not want a string to parse in a fixed representation that will be incorrect. e.g.:
auto f = Fixed!2("10000000000000005.00");
writeln(f); // 10000000000000004.00
Second, it requires sscanf, under the hood. It does black magic. I'd rather not rely on black magic. Or libc if possible ;)
Third, parsing 2 integers instead of a double is way faster. Again parsing floating point is black magic, and really really hard to get right. It's why D still relies on sscanf.
I was considering using this in a project of mine. But I can't accept this limitation. I may create a PR if this might be approved. But the statement in the readme saying "Perhaps change the string -> fixed algorithm to avoid using floating point. Not sure if it is worth the effort" gives me pause.
Let me know.
@jaypha Are you going to abandon this project?
I plan to maintain it and move to:
https://github.com/dlang-community
If you got a change to reply.
Thanks.
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.