Re: Bug in expr ?
- From: Michael Schlenker <schlenk@xxxxxxxxxxxxxxxx>
- Date: Sun, 02 Jul 2006 22:35:33 +0200
tunity5@xxxxxxxxx schrieb:
stephanearnold@xxxxxxxx wrote:So use floating point arithmetics and force rounding in a way you like.
Hi,
IMHO there is no relation with floats. It is the rule that, given A & B
positive,
(A modulo B) and (-A modulo B) cannot be negative. (it is a convention)
I don't follow you wrote.
Perhaps, I can provide some background into how I came across this
behavior:
########## find out how many days between any two dates
########## specifically, number of 24-hour spans between them
######### set up
set one_day [expr 60 * 60 * 24]
set today [clock seconds]
set yesterday [clock scan "july 2, 2006"]
#### ordering #1
% expr ($today - $yesterday) / $one_day
0
#### ordering #2
% expr ($yesterday - $today) / $one_day
-1
So, the question is, what is the answer? Note that I am OK with either
answer (0 or 1), depending on what you view as a "day" but I would like
to get the same result from both expressions.
Michael
.
- References:
- Bug in expr ?
- From: tunity5
- Re: Bug in expr ?
- From: Michael Schlenker
- Re: Bug in expr ?
- From: tunity5
- Re: Bug in expr ?
- From: Eric Hassold
- Re: Bug in expr ?
- From: tunity5
- Re: Bug in expr ?
- From: stephanearnold
- Re: Bug in expr ?
- From: tunity5
- Bug in expr ?
- Prev by Date: Re: Bug in expr ?
- Next by Date: Re: Bug in expr ?
- Previous by thread: Re: Bug in expr ?
- Next by thread: Re: Bug in expr ?
- Index(es):
Relevant Pages
|