Giter VIP home page Giter VIP logo

Comments (6)

alkis avatar alkis commented on June 6, 2024

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.

trolleyman avatar trolleyman commented on June 6, 2024

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.

trolleyman avatar trolleyman commented on June 6, 2024

At the moment I think d128::from_bytes is a good workaround.

from decimal.

alkis avatar alkis commented on June 6, 2024

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.

trolleyman avatar trolleyman commented on June 6, 2024

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.

alkis avatar alkis commented on June 6, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.