All pastes #720119 Raw Edit

Mine

public text v1 · immutable
#720119 ·published 2007-09-30 00:14 UTC
rendered paste body
alias Rnd {
  if ($isid) {
    var %x = $1, %y = 1
    if ($1 !isnum || $2 == $null || $2 !isnum || $2 >= $len($1) || $3 && $3 !isnum || *.* iswm $1) { return }
    elseif ($1 isnum) {
      while (%y <= $2) {
        var %this = %this $+ 0
        inc %y
      }
      if ($2 == 0) { return $round($1,0) }
      if ($right($1,$2) == %this) return $1
      elseif ($right($1,$2) != %this) {
        if (!$3) {
          :meh
          if ($right($1,$2) >= 5 $+ $right(%this,$calc($2 -1))) { inc %x }
          elseif ($right($1,$2) < 5 $+ $right(%this,$calc($2 -1))) { dec %x }
          if ($right(%x,$2) != %this) { goto meh }
          return %x
        }
        elseif ($3 && $3 == 1) {
          :teh
          inc %x
          if ($right(%x,$2) != %this) { goto teh }
          return %x
        }
      }
    }
  }
}