Skip to content

Commit

Permalink
Add runtime mod
Browse files Browse the repository at this point in the history
  • Loading branch information
Smit-create committed Apr 6, 2022
1 parent 1d327aa commit e8c7abf
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/runtime/lpython_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,3 +469,20 @@ def _lpython_floordiv(a: i64, b: i64) -> i64:
if r >= 0.0 or result == r:
return result
return result - 1


@overload
def _mod(a: i32, b: i32) -> i32:
return a - _lpython_floordiv(a, b)*b

@overload
def _mod(a: f32, b: f32) -> f32:
return a - _lpython_floordiv(a, b)*b

@overload
def _mod(a: i64, b: i64) -> i64:
return a - _lpython_floordiv(a, b)*b

@overload
def _mod(a: f64, b: f64) -> f64:
return a - _lpython_floordiv(a, b)*b

0 comments on commit e8c7abf

Please sign in to comment.