NEWTON

NEWTON


Popular tags

    AssertionError with range_check_ptr_ptr

    Asked

    4 months ago

    72

    views


    0

    Hello world!

    I try to implement the function abs_value of the package starkware.cairo.common.math but i have this error

    AssertionError: Expected main to contain the following arguments (in this order): ['range_check_ptr_ptr']. Found: ['range_check_ptr'].
    

    I dont understand the error.

    Can someone explain the error to me, why it happens ?

    I am doing the challenge #17daysOfCairo of the day 3

    Full code

    %builtins range_check_ptr
    from starkware.cairo.common.math import abs_value
    
    func main{range_check_ptr}() {
        let x = abs_value(-1);
        return ();
    }
    
      cairo

    chocolaite

    asked

    4 months ago


    1 answers

    1

    Accepted answer

    You actually don't need to import the range_check_ptr but actually the range_check built-in (check this link). Change your code to

    %builtins range_check
    from starkware.cairo.common.math import abs_value
    
    func main{range_check_ptr}() {
        let x = abs_value(-1);
        return ();
    }
    

    and it should compile and run.

    answered

    4 months ago

    Your answer

    NEWTON

    NEWTON