exponential2normal
This commit is contained in:
parent
1619fd79c4
commit
860af0e870
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
function g_num_exponential2normal {
|
function g_num_exponential2normal {
|
||||||
[ -z "$1" ] && return 1
|
[ -z "$1" ] && return 1
|
||||||
# if there is a exponential number (for example 9.881e-05) convert it to "normal" notation
|
# if there is a exponential number (for example 9.881e-05) convert it to "normal" notation
|
||||||
@ -6,9 +7,11 @@ function g_num_exponential2normal {
|
|||||||
# convert
|
# convert
|
||||||
printf -v f_g_num_exponential2normal_result -- "%.12f" "$1"
|
printf -v f_g_num_exponential2normal_result -- "%.12f" "$1"
|
||||||
# remove ending 0
|
# remove ending 0
|
||||||
if [[ $f_g_num_exponential2normal_result =~ \. ]]
|
if [[ $f_g_num_exponential2normal_result =~ \. ]]
|
||||||
f_g_num_exponential2normal_result=${f_g_num_exponential2normal_result%%+(0)}
|
then
|
||||||
f_g_num_exponential2normal_result=${f_g_num_exponential2normal_result%%.}
|
f_g_num_exponential2normal_result=${f_g_num_exponential2normal_result%%+(0)}
|
||||||
|
f_g_num_exponential2normal_result=${f_g_num_exponential2normal_result%%.}
|
||||||
|
fi
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
f_g_num_exponential2normal_result=$1
|
f_g_num_exponential2normal_result=$1
|
||||||
|
Loading…
Reference in New Issue
Block a user