Comments (6)
Will something like this work?
const D0 = d128!(0);
const D1 = d128!(1);
// more consts here
impl d128 {
pub fn zero() -> d128 { D0 }
pub fn one() -> d128 { D1 }
// more functions here
}
Also are we sure we want more than 0, 1, +inf, -inf and nan?
from decimal.
const D0 = d128!(0);
doesn't work atm as d128!(0)
just becomes { use std::str::FromStr; d128::from_str(0) }
which isn't a constant function. Another option is reimplementing the d128
macro as a plugin that converts the string at compile time.
from decimal.
At the moment I think d128::from_bytes
is a good workaround.
from decimal.
How about:
impl d128 {
pub fn zero() -> d128 { d128!(0) }
pub fn one() -> d128 { d128!(1) }
// more functions here
}
This means we will have the functions but they will be inefficient. When plugins are ready we can make them fast.
My main problem with with_bytes it is that it is very hard to use.
from decimal.
Yeah, the problem with this is that it is still calculating the numbers at runtime. Is there a way, using the plugin API, to compile the library and use one of the functions, then get the return value and hard code it in?
from decimal.
I don't know if there is a way. But what I know is that it is still not stabilized and available only on nightly. For that reason I want to wait until it makes it to beta before implementing something for it.
from decimal.
Related Issues (20)
- guidance on writing f64, f32 conversion HOT 2
- Error compiling library on Raspbian
- sin() / cos() / tan() methods HOT 4
- Incorrect formatting HOT 2
- quantize() with quantum >1 doesn't work properly
- compilation fails on ppc64le, s390x, aarch64, armv7hl HOT 4
- unsigned d128
- Consider to move the crait in `rust_num`
- sqrt method HOT 1
- remove rustc-serialize HOT 4
- d128::from_str() returns Ok on non valid inputs HOT 1
- UB and usage of deprecated function HOT 10
- `from_str` panic HOT 2
- status of the project HOT 2
- Two d128 values are equal, but their hashes aren't
- d128 to integer value HOT 2
- `exp` causes infinite loop
- how to add this library with my own C program
- const literals? HOT 3
- Provide bindings to `decNumberRescale`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from decimal.