https://github.com/juliacomputing/scalednumbersoutput.jl
Pretty printing of numbers that are rounded and in SI notation (eg 3.25n)
https://github.com/juliacomputing/scalednumbersoutput.jl
Last synced: 10 months ago
JSON representation
Pretty printing of numbers that are rounded and in SI notation (eg 3.25n)
- Host: GitHub
- URL: https://github.com/juliacomputing/scalednumbersoutput.jl
- Owner: JuliaComputing
- License: mit
- Created: 2022-05-13T18:20:35.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-08T17:26:27.000Z (over 3 years ago)
- Last Synced: 2025-01-20T21:51:42.758Z (11 months ago)
- Language: Julia
- Size: 10.7 KB
- Stars: 2
- Watchers: 6
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ScaledNumbersOutput
This package provides a utility function for pretty printing
numbers. The `to_SI(val; sigdigits)` takes a number and converts
it to the a string using SI scaling prefixes. For example:
```julia
julia> to_SI(75.2e10)
"752G"
julia> to_SI(0.000000021)
"21n"
```
By default numbers are rounded to 5 digits but that can be chosen:
```julia
julia> to_SI(1/9)
"0.11111"
julia> to_SI(1/9, sigdigits=7)
"0.1111111"
```
The following scale factors are supported:
| Symbol | Scaling Factor|
|:------:|--------------:|
| P | 10^15 |
| T | 10^12 |
| G | 10^9 |
| M | 10^6 |
| k | 10^3 |
| m | 10^-3 |
| u | 10^-6 |
| n | 10^-9 |
| p | 10^-12 |
| f | 10^-15 |
| a | 10^-18 |
## See also
The following packages are similar:
- [ScalingNumbersInput](https://github.com/JuliaComputing/ScaledNumbersInput.jl) - for using scaling factors when reading numbers
- [NumericIO](https://github.com/ma-laforge/NumericIO.jl) - similar functionality