Hi All,
I am writing a function at the moment to calculate the value of an byte offset for a floppy disk image but for some reason the long integer I am using to store this value is signed despite explicitly declaring it as unisgned. Also where the function value is return to, if this is given the correct value there is no problem so it appears to be limited to this function. Any ideas?
Code is:
Value of Sect: 3
Value of Cyl: 6
Value of Hd: 1
value that should be returned by this is 120832 but actual value is -10240
Thanks,
Dinklebaga
I am writing a function at the moment to calculate the value of an byte offset for a floppy disk image but for some reason the long integer I am using to store this value is signed despite explicitly declaring it as unisgned. Also where the function value is return to, if this is given the correct value there is no problem so it appears to be limited to this function. Any ideas?
Code is:
Code:
find_offset(sect, cyl, hd) char sect, hd, cyl; { char sectorsize = 512; unsigned long offset = 0; offset = (cyl*2)*18; printf("offset = %d\n", offset); if(hd == 1) { offset = (offset + 18); } printf("offset = %d\n", offset); offset = (offset + sect); printf("offset = %d\n", offset); offset = (offset * 512); printf("offset = %d\n", offset); offset = (offset - 512); printf("offset = %d\n", offset); return(offset); }
Value of Cyl: 6
Value of Hd: 1
value that should be returned by this is 120832 but actual value is -10240
Thanks,
Dinklebaga
Comment