NEWTON

NEWTON


Popular tags

    Cairo: Using less than or greater than in conditional

    Asked

    6 months ago

    3

    views


    0

    What is the best way to check if a value is less than another value in a conditional? Say if x > y, then do something

    This question was originally posted on Triality

      cairocairo-lang

    1 answers

    0

    For less than or equal use the following:

    Make sure you import

    from starkware.cairo.common.math_cmp import is_le

    and then you can use the following statement

    let (isLe) = is_le(0, 1)

    #if the first value is less than or equal to the second then you get 1, if first value is greater than the second you get 0.

    if isLe == 1:

    #Do something for a less than or equal scenario

    end

    This answer was originally posted on Triality

    answered

    7 months ago

    Your answer

    NEWTON

    NEWTON