<html>
<head>
<base href="http://bugzilla.scilab.org/" />
</head>
<body><br>
---------- Bug Summary ----------- <br>printf cannot handle uint64 integers greater than 2^32-1 <br><br>
<br>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - printf cannot handle uint64 integers greater than 2^32-1"
href="http://bugzilla.scilab.org/show_bug.cgi?id=15442#c10">Comment # 10</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - printf cannot handle uint64 integers greater than 2^32-1"
href="http://bugzilla.scilab.org/show_bug.cgi?id=15442">bug 15442</a>
from <span class="vcard"><a class="email" href="mailto:stephane.mottelet@utc.fr" title="Stéphane MOTTELET <stephane.mottelet@utc.fr>"> <span class="fn">Stéphane MOTTELET</span></a>
</span></b>
<pre>Under Linux, printf is anyway buggy, as the following code x=uint64(2^32-1)
x=uint64(2^32)
printf("%u\n",x)
printf("%lu\n",x)
printf("%d\n",x)
printf("%ld\n",x)
displays
0
4294967296
-2147483648
2147483648
i.e. OK (by which miracle) for %lu but erroneous for %d and %ld.
To me the reference behavior (and the one obtained in Scilab after the proposed patch) is the one of the following C code :
#include <stdio.h>
int main()
{
unsigned long int x=4294967296;
printf("%u\n",x);
printf("%lu\n",x);
printf("%d\n",x);
printf("%ld\n",x);
return 0;
}
which outputs, under all operating systems
0
4294967296
0
4294967296</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are watching all bug changes.</li>
</ul>
</body>
</html>