Cairo: How would I store negative numbers then retrieve them as negatives?

Viewed 25

I am trying to store a negative number, and then on a function call, read it. But I only get the positive Felt number.

This question was originally asked in Triality (link), a knowledge-sharing community built for web3 developers

1 Answers

Felts are module P (a big prime) so -1 == P - 1 that's why you only see positive numbers. If you wish to do mathematical operations that take into account the sign of the felt you can use the functions prefixed with sign here.

Related