Sam's answer indicates that this is is a result of an efficient implementation within Perl, which I would argue, using the principle of least surprise, is a bug if it gives incorrect answers for math that could be handled within an int. Perhaps a pragma forcing the local implementation to be used would be a reasonable compromise. I'm not sure Graham's answer covers it -- program below prints "247", while perl prints "246", so sprintf isn't behaving the same as the underlying C. -- Sal smile. #include <stdio.h> int main(void) { float a = 2.47; char buf[100]; sprintf(buf, "%d", int(a * 100)); printf("%s\n", buf); return 0; }Thread Next