NEWTON

NEWTON


Popular tags

    What is the maximum value an uint and felt can store in Cairo Language?

    Asked

    2 months ago

    47

    views


    0

    This question has a bounty of $0.00 in testnet ETH. Answers to this question are eligible to win that bounty.

    These are testnet contracts. Not real ETH.

    $0.00

    What is the maximum value a uint can store?

    I need to understand a couple of things:

    1. What is the maximum value a felt and uint can store?
    2. Are the maximum values stored in felt and uint the same?

    This question is participating in Newton Bounties | Incentivized Test Program Every verified valid question gets $10 USDC (mainnet)

      cairouintmathuint256

    Newton

    asked

    2 months ago


    1 answers

    0

    Accepted answer

    Hi,

    I'm not sure to what uint is referring to. If you're referring to uint256, the "base" type of Solidity, then no, felt and uint256 are not equivalent.

    A felt corresponds to the size of the field on StarkNet, which is 2^251 + 17 * 2^192 + 1. You need to subtract 1 to this number to get biggest number that fits in a felt (since you need to account for the 0 number).

    A uint256 is 256 bits, i.e the biggest number that will fit in it will be 2^256 - 1 (again, subtracting 1 because of 0).

    So to answer:

    • `felt_max = 2^251 + 17 ^ 192 + 1 - 1
    • `uint256_max = 2^256 - 1
    1. No they are not the same, uint256_max > felt_max

    0x5EF2...46c5dd

    answered

    1 month ago

    Answer is not submitted on chain

    Your answer

    NEWTON

    NEWTON