Skip to content

Commit

Permalink
correcting to_float() function to print maximum 5 digits after precis…
Browse files Browse the repository at this point in the history
…ion point
  • Loading branch information
kasra-keshavarz committed Jan 29, 2023
1 parent df2b36c commit 03d742f
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion canrcm4_wfdei_gem_capa/canrcm4_wfdei_gem_capa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ unix_epoch () { date --date="$@" +"%s"; }
check_real () { if [[ "$1" == *'.'* ]]; then echo 'float'; else echo 'int'; fi; }

#convert to float if the number is 'int'
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "$1"; echo; fi; }
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "%.5f" "$1"; echo; fi; }

#join array element by the specified delimiter
join_by () { local IFS="$1"; shift; echo "$*"; }
Expand Down
2 changes: 1 addition & 1 deletion conus_i/conus_i.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ format_date () { date --date="$1" +"$2"; }
check_real () { if [[ "$1" == *'.'* ]]; then echo 'float'; else echo 'int'; fi; }

#convert to float if the number is 'int'
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "$1"; echo; fi; }
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "%.5f" "$1"; echo; fi; }

#join array element by the specified delimiter
join_by () { local IFS="$1"; shift; echo "$*"; }
Expand Down
2 changes: 1 addition & 1 deletion conus_ii/conus_ii.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ format_date () { date --date="$1" +"$2"; }
check_real () { if [[ "$1" == *'.'* ]]; then echo 'float'; else echo 'int'; fi; }

#convert to float if the number is 'int'
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "$1"; echo; fi; }
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "%.5f" "$1"; echo; fi; }

#join array element by the specified delimiter
join_by () { local IFS="$1"; shift; echo "$*"; }
Expand Down
2 changes: 1 addition & 1 deletion era5/era5_simplified.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ unix_epoch () { date --date="$@" +"%s"; }
check_real () { if [[ "$1" == *'.'* ]]; then echo 'float'; else echo 'int'; fi; }

#convert to float if the number is 'int'
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "$1"; echo; fi; }
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "%.5f" "$1"; echo; fi; }

#join array element by the specified delimiter
join_by () { local IFS="$1"; shift; echo "$*"; }
Expand Down
2 changes: 1 addition & 1 deletion rdrs/rdrs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ unix_epoch () { date --date="$@" +"%s"; }
check_real () { if [[ "$1" == *'.'* ]]; then echo 'float'; else echo 'int'; fi; }

#convert to float if the number is 'int'
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "$1"; echo; fi; }
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "%.5f" "$1"; echo; fi; }

#join array element by the specified delimiter
join_by () { local IFS="$1"; shift; echo "$*"; }
Expand Down
2 changes: 1 addition & 1 deletion wfdei_gem_capa/wfdei_gem_capa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ unix_epoch () { date --date="$@" +"%s"; }
check_real () { if [[ "$1" == *'.'* ]]; then echo 'float'; else echo 'int'; fi; }

#convert to float if the number is 'int'
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "$1"; echo; fi; }
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "%.5f" "$1"; echo; fi; }

#join array element by the specified delimiter
join_by () { local IFS="$1"; shift; echo "$*"; }
Expand Down

0 comments on commit 03d742f

Please sign in to comment.