Project

General

Profile

« Previous | Next » 

Revision 9364

lib/sh/util.sh: added float functions (esp. float+int()) for dealing with decimal verbosities used by sql.py and column-based import

View differences:

util.sh
139 139
bool2int() { try test ! "$1"; echo "$e"; } # empty->0; non-empty->1
140 140

  
141 141

  
142
#### floats
143

  
144
int_part() { echo "${1%%.*}"; }
145

  
146
dec_suffix() { echo "${1#$(int_part "$1")}"; }
147

  
148
round_down() { int_part "$1"; }
149

  
150
float+int() { echo "$(($(int_part "$1")+$2))$(dec_suffix "$1")"; }
151

  
152

  
142 153
#### strings
143 154

  
144 155
repeat() # usage: str=... n=... repeat

Also available in: Unified diff