Scientic rounding functions?

#1

Is there an equivalent of Perl Math::Round package in Julia?
http://search.cpan.org/~grommel/Math-Round-0.07/Round.pm

I have found this very useful in the past, the package properly rounds off floating point numbers to a given decimal place.
This very good article https://medium.com/@Jernfrost/defining-custom-units-in-julia-and-python-513c34a4c971
has one place where:
julia> Fahrenheit(3) + Celsius(4) + Kelvin(4)
Kelvin(265.0388888888889)
Erik - great article, and I learned from it. Just that for me that figure should be rounded off…

#2

Maybe you can specify what is missing in `round`?

#3

Mauro, thankyou. Yes of course I shoudl have looked there.
IWill see how the rounding is implemented.

#4

round(1.65429842, 3) will yield 1.654

#5

I find this useful sometimes to round to a nearest multiple of something:

``````roundnearest(num, frac) = round(num * (1/frac)) * frac
``````
``````julia> using UnicodePlots
julia> lineplot(1:100, roundnearest.(1:100, 25), canvas=AsciiCanvas)
┌────────────────────────────────────────┐
100 │                                   F""""│
│                                   |    │
│                                  |     │
│                         _________J     │
│                         |              │
│                        .`              │
│                        |               │
│               r--------f               │
│               |                        │
│              ,`                        │
│              |                         │
│     F"""""""""                         │
│     |                                  │
│    ,`                                  │
0 │.___J                                   │
└────────────────────────────────────────┘
0                                      100
``````

Wouldn’t call it scientific, though (or even ‘scientic’)…