Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 12/17/19 in all areas

  1. 1 point
    meko

    Error in changer coin

    10 to the power of 10 is 10,000,000,000 but the scripting engine uses signed 32-bit integers and the maximum value that can be held by such integers is 2,147,483,647 (2^31 − 1). Any value above this will cause the integer to overflow so you have to be aware of this and manually check the boundaries. In your case this would mean checking that getarg(0) is shorter than 10 characters long so if ( .@num == 0 || .@num >= 10 ** 9 ) return getarg(0); instead of if ( .@num == 0 || .@num >= 2147483647 ) return getarg(0); to avoid the case where getstrlen is above 10
  2. 1 point
    meko

    Error in changer coin

    .@num$ = .@num % 10 ** (.@i + 1) / 10 ** .@i + .@num$;
  3. 1 point
    4144

    Error in changer coin

    If you not understand math, can you simply copy/paste fixed line?
  4. 1 point
    meko

    Error in changer coin

    the exponentiation operator (**) has higher precedence than the addition operator (+) so this means A ** B+C is interpreted as (A ** B) + C because the exponentiation operation has priority over the addition operation also worth noting that exponentiation has higher precedence than multiplication/division so a more complex formula like A + B * C ** D would be interpreted as A + (B * (C ** D)) so you have to manually reorder the operations with explicit parentheses if you want to change the precedence, like (A + (B * C)) ** D
  5. 1 point
    4144

    Error in changer coin

    try like this: (10**(.@i+1)) / (10**.@i)
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.