Re: calculate time span
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: calculate time span

From: Lisa Pearlson <no@spam.plz>
Date: Wed Mar 01 2006 - 01:21:43 CET

Another thing, in my timespan proc, I divide the number of seconds by the
number of seconds for that unit, with a decimal value.

For example, for the number of days:

set seconds [clock seconds]
set weeks [expr { $seconds / 604800.0 }]

I don't divide by intiger 604800 but by floating point 604800.0 so that the
result will be floating point value.
If I don't do this, 1.9 days would be automatically rounded to integer value
2, while my wholeunits will floor it for positive values and ceil it for
negative ones to gets whole numbers.

Is this okay? how large can floating point values be? How many digits before
the decimal and how many after?

Lisa
Received on Sun Apr 30 02:18:10 2006