From 860af0e870abd3ba6bda278b1b2a21b28bc28acb Mon Sep 17 00:00:00 2001 From: olli <> Date: Sun, 23 Jun 2024 13:15:28 +0200 Subject: [PATCH] exponential2normal --- gaboshlib/g_num_exponential2normal.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gaboshlib/g_num_exponential2normal.sh b/gaboshlib/g_num_exponential2normal.sh index e1bd5e6..5092a3a 100644 --- a/gaboshlib/g_num_exponential2normal.sh +++ b/gaboshlib/g_num_exponential2normal.sh @@ -1,3 +1,4 @@ +#!/bin/bash function g_num_exponential2normal { [ -z "$1" ] && return 1 # 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 printf -v f_g_num_exponential2normal_result -- "%.12f" "$1" # remove ending 0 - if [[ $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%%.} + if [[ $f_g_num_exponential2normal_result =~ \. ]] + then + f_g_num_exponential2normal_result=${f_g_num_exponential2normal_result%%+(0)} + f_g_num_exponential2normal_result=${f_g_num_exponential2normal_result%%.} + fi return 0 else f_g_num_exponential2normal_result=$1