sway icon indicating copy to clipboard operation
sway copied to clipboard

Fixed point numbers library

Open rostyslavtyshko opened this issue 3 years ago • 2 comments

Adding fixed point numbers library akin to https://github.com/abdk-consulting/abdk-libraries-solidity

Adding basic math functionality to other connected types i.e. u8/16/32/64/128

rostyslavtyshko avatar Jun 21 '22 09:06 rostyslavtyshko

@rostyslavtyshko can you clarify what was happening that was causing the related bug on this PR?

emilyaherbert avatar Jun 21 '22 17:06 emilyaherbert

@rostyslavtyshko can you clarify what was happening that was causing the related bug on this PR?

Compiling Sway and the library works as expected however when you attempt to import the U128 type (for testing) and use the Expo trait with the pow() function it would complain that pow() does not exist no matter how it was imported and where it was located.

E.g. some_u128_var.pow() with the error that pow() is not found on the type.

The strange thing is that other traits defined within the same file, or other files, for the U128 have been discovered and worked as expected. The expo trait seemed to not exist within tests at all despite the library itself compiling as expected.

Sorry, got ahead of myself and edited your comment by accident

Braqzen avatar Jun 21 '22 17:06 Braqzen

As discussed previously, it's better to move this PR to the sway-libs repository. Once https://github.com/FuelLabs/sway/issues/2873 is resolved, we can bring back all the math libraries into sway-lib-std.

Changing this to a draft in the meantime.

mohammadfawaz avatar Oct 05 '22 18:10 mohammadfawaz

I'm going to close this in favor of https://github.com/FuelLabs/sway-libs/pull/32 and https://github.com/FuelLabs/sway-libs/pull/31.

mohammadfawaz avatar Oct 31 '22 19:10 mohammadfawaz