File tree Expand file tree Collapse file tree 1 file changed +22
-5
lines changed
functions_scripts/scripting/bash Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Original file line number Diff line number Diff line change 99
1010# Conversion
1111# --------------------------------------------
12- # Convert a time in seconds (using either an integer or decimal) to
13- # millseconds as a decimal.
12+ # Convert seconds to milliseconds with decimal precision.
1413 # Usage:
1514 # secondsToMillisecondsDecimal <seconds>
1615 secondsToMillisecondsDecimal () {
1716 printf ' %.4f' " $( bc <<< " ${1}*1000" ) "
1817 }
1918
20- # Convert a time in seconds (using either an integer or decimal) to
21- # millseconds as an integer rounded to the nearest tenths place (using round
22- # half towards zero mode).
19+ # Convert seconds to milliseconds.
2320 # Usage:
2421 # secondsToMilliseconds <seconds>
22+ # Notes:
23+ # The number is rounded to the nearest tenths place using half toward zero
24+ # rounding mode.
2525 secondsToMilliseconds () {
2626 printf ' %.0f' " $( secondsToMillisecondsDecimal " ${1} " ) "
2727 }
2828
29+ # Convert seconds to microseconds with decimal precision.
30+ # Usage:
31+ # secondsToMicrosecondsDecimal <seconds>
32+ secondsToMicrosecondsDecimal () {
33+ printf ' %.4f' " $( bc <<< " ${1}*1000000" ) "
34+ }
35+
36+ # Convert seconds to microseconds.
37+ # Usage:
38+ # secondsToMicroseconds <seconds>
39+ # Notes:
40+ # The number is rounded to the nearest tenths place using half toward zero
41+ # rounding mode.
42+ secondsToMicroseconds () {
43+ printf ' %.0f' " $( secondsToMicrosecondsDecimal " ${1} " ) "
44+ }
45+
You can’t perform that action at this time.
0 commit comments