Skip to content

Commit

Permalink
add number.floor() method
Browse files Browse the repository at this point in the history
  • Loading branch information
kaidesu committed Nov 20, 2023
1 parent f234348 commit 14cde84
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions object/number.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ func (number *Number) Method(method string, args []Object) (Object, bool) {
switch method {
case "round":
return number.round(args)
case "floor":
return number.floor(args)
case "toString":
return number.toString(args)
}
Expand Down Expand Up @@ -56,3 +58,7 @@ func (number *Number) round(args []Object) (Object, bool) {

return &Number{Value: number.Value.Round(int32(places.Value.IntPart()))}, true
}

func (number *Number) floor(args []Object) (Object, bool) {
return &Number{Value: number.Value.Floor()}, true
}

0 comments on commit 14cde84

Please sign in to comment.