Integer division / std.trunc ?
Open
stdlib
- Dominant language
- Jsonnet
- Stars
- 7.6k
- Forks
- 475
- PR merge metrics
- No merged PRs in 30d
Description
It's easy to get the remainder when dividing two integers:
```
$ jsonnet -e -- '105 % 100'
5
$ jsonnet -e -- '-105 % 100'
-5
```
But I found it unexpectedly awkward to do the actual division:
```
$ jsonnet -e -- 'std.floor(105 / 100)'
1
$ jsonnet -e -- 'std.floor(-105 / 100)'
-2
```
In javascript there would be `Math.trunc` for this. Of course, you can write it yourself if you need it.
I wonder if `std.trunc` would be a useful addition? Or `std.div` for integer division?
Contributor guide
Assessment
This issue has not been assessed yet.