Re: segmentation fault with fclose

2011-03-22 Thread Jeremy Hall
Try the "comp.lang.c.moderated" group for C and C library questions. You probably meant: if( fp != NULL ) fclose( fp ); That is, "!= NULL" rather than "== NULL".

Re: Problem with scanf reading long types in scientific notation

2011-05-19 Thread Jeremy Hall
Try strtold() perhaps. It happily reads all the formats (15892938475, 1.5892938475E10 etc) you asked for. If the significand part of the float is as large or larger than the int type, then you can convert the result to an int type with no loss of precision. 80 bit long double (common on x86) has

Re: Option to make unsigned->signed conversion always well-defined?

2011-10-06 Thread Jeremy Hall
Hi. Instead of all the clever bit twiddling I have used code similar to sum > UINT8_MAX which just generates cmp ax,255 seta al which seems to be far more efficient (even the signed version gets optimized down to the above single check). Please could someone tell me if I have

Possible improvement in inline stringop code generation

2010-11-18 Thread Jeremy Hall
Hi Folks, GCC 4.5.1 20100924 "-Os -minline-all-stringops" on Core i7 int main( int argc, char *argv[] ) { int i, a[256], b[256]; for( i = 0; i < 256; ++i ) // discourage optimization a[i] = rand(); memcpy( b, a, argc * sizeof(int) ); printf( "%d\n", b[rand()] ); // discourag