Comments (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
anddiv
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)
- Make `UD60x18-pow` work with values lower than 1e18
- Write fuzz tests
- Incorrect uEXP2_MAX_INPUT for UD60x18 and SD59x18 HOT 1
- Document UDVTs with NatSpec comments
- Audit report HOT 3
- Backport `Fix bit mask in Common.exp2 function` to v3.3.* HOT 3
- `SD59x18.exp` reverts on hugely negative numbers HOT 3
- overflow classification and error is inconsistent on divide by zero in mulDiv HOT 1
- Add support for `uint128` tpye
- HardHat Instilation broken HOT 1
- Integrate Slither for continuous static analysis
- A `sign` function for signed types HOT 1
- Incorrect types for uUNIT in UD2x18 and SD1x18
- Use fuzz test fixtures
- Update EVM Version to `Shanghai` HOT 1
- Console.log for the UD60x18, SD59x18 types HOT 2
- Make domain bound specs more visually descriptive
- Remove casting functions between the adjacent types
- Incorrect requirement spec in UD60x18.log2
- Hardhat compile error with @openzeppelin/hardhat-upgrades HOT 3
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 prb-math.