Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CellData.put_arbitrary_int is broken #17

Open
gromgull opened this issue May 16, 2024 · 0 comments
Open

CellData.put_arbitrary_int is broken #17

gromgull opened this issue May 16, 2024 · 0 comments

Comments

@gromgull
Copy link

        if _int < 0:
            self.put_bool(1)
            s = 2 ** (bitsize - 1)
            self.put_arbitrary_uint(s - _int, bitsize - 1)
        else:
            self.put_bool(0)
            self.put_arbitrary_uint(_int, bitsize - 1)

The s - _int must be s + _int (since _int is negative)

otherwise you get a Exception: Not enough bits (1) to encode integer (3) error

Try:

from tvm_valuetypes.cell import Cell
c = Cell()
c.data.put_arbitrary_int(-1, 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant