HELP !! Why doesn't it run on my machine ???
Amos Shapir
amos at taux01.UUCP
Mon Sep 11 00:18:18 AEST 1989
Your problems seems to be bad programming, not bad coding. Instead of
computing an exact value directly, you introduce inexactness by using
floating-point (which might be rounded differently on different machines)
then trying to improve the generated 'guess' by binary search.
Here is a better algorithm, which computes day number from a given date;
I leave changing the epoch and adding the hour/minute stuff as an exercise
to the reader :-)
o / o / o / o /
--Cut-here-------X---------------X---------------X---------------X----
o \ o \ o \ o \
/*
* Gauss's formula - days since the 1.1.70 epoch
*/
days(d, m, y)
register m, y, d;
{
if(y < 100)
y += 1900;
if((m -= 2) <= 0) {
m += 12;
y--;
}
/* Gregorian calendar */
d += 365*y+y/4-y/100+y/400+367*m/12-719499;
return d;
}
o / o / o / o /
--Cut-here-------X---------------X---------------X---------------X----
o \ o \ o \ o \
May the Source be with you, always...
--
Amos Shapir amos at taux01.nsc.com or amos at nsc.nsc.com
National Semiconductor (Israel) P.O.B. 3007, Herzlia 46104, Israel
Tel. +972 52 522261 TWX: 33691, fax: +972-52-558322
34 48 E / 32 10 N (My other cpu is a NS32532)
More information about the Comp.unix.wizards
mailing list