GithubHelp home page GithubHelp logo

Comments (1)

PaulRBerg avatar PaulRBerg commented on August 31, 2024 1

SD59x18 something = SD59x18.ln(SD59x18.wrap(int256(2)));

It is not possible to use the functions defined in user-defined value types in this way.

The correct way is to access the functions by using the dot operator, like this:

SD59x18 x = SD59x18.wrap(2);
SD59x18 something = x.ln();

Alternatively, you could also import the ln function, like this:

import { ln } from "@prb/math/sd59x18/Math.sol";

SD59x18 x = SD59x18.wrap(2);
SD59x18 something = ln(x);

Finally, note that you can make the typecasting look prettier (more succinct) using the sd casting utility:

import { sd } from "@prb/math/SD59x18.sol";

SD59x18 x = sd(2);
SD59x18 something = x.ln();

Other functions such as wrap and div are working just fine.

wrap works because that's a built-in function compiler. div doesn't work, so I'm not sure how you got it working. This code does not compile:

SD59x18 x = SD59x18.wrap(2);
result = SD59x18.div(x, x);

the linter complains about assembly ("memory-safe")

That is not an issue with the linter but with the VSCode Solidity extension:

juanfranblanco/vscode-solidity#386

from prb-math.

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.