[cc65] bug in shifts of long-type values

Date view Thread view Subject view

From: Sidney Cadot (sidney_at_janis.pds.twi.tudelft.nl)
Date: 2000-03-11 20:49:17


Hi,

There seems to be a bug in the shifting of 'long' type variables:

int main(void)
{
  int i;
  unsigned long ul;
  signed long sl;

  clrscr();

  for(i=0;i<32;i++)
    {
      ul = (1UL)<<i;
      sl = (1L)<<i;
      cprintf("%d %lu %ld\n",i,ul,sl);
    }

  return 0;
}

produces correct results only for i<16, zero otherwise. May have either
something to do with buggy shift-code or otherwise an invalid type
inference by the compiler...

Best regards,

  Sidney

+--------------------------------------------------------------------------+
| -- Sidney Cadot - sidney_at_ch.twi.tudelft.nl - ITS/TU Delft - tst. 3850 -- |
+--------------------------------------------------------------------------+
|/* C-code to calculate day-of-week (1901-2099). Type name for man page. */|
|main(int c,char**v){exit(printf("%sday.\n","Use MM/DD/YYYY argument to c" |
|"alculate week\0Mon\0/0/Tues\0/0Wednes\0Thurs\0/Fri\0/0/Satur\0/Sun"+(*++ |
|v?42+((5*atoi(6+*v)+"@GSTDLXDP_at_HT@"[atoi(*v)])/4+atoi(3+*v))%7*7:0))/30);}|
+--------------------------------------------------------------------------+



----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2001-12-14 22:05:35 CET