php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21658 Strange sprintf behaviour
Submitted: 2003-01-15 08:06 UTC Modified: 2003-01-17 05:50 UTC
From: andrea at euronia dot it Assigned:
Status: Closed Package: *General Issues
PHP Version: 4.3.0 OS: Gentoo Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: andrea at euronia dot it
New email:
PHP Version: OS:

 

 [2003-01-15 08:06 UTC] andrea at euronia dot it
mod_php 4.3.0 produce a strange sprintf behaviour

for($t=0;$t<10;$t++) {
	$r=(float) rand(0,10000)/3;
	echo $r." -> ".sprintf('%.3f',$r)."\n";
}

will produce ...

1975.33333333 -> ?.000
508.333333333 -> ,.000
2483.66666667 -> ?.000
61.6666666667 -> m.000
2514.66666667 -> I00.000
2499.66666667 -> *0.000
1957.33333333 -> ?0000.000
3167.33333333 -> 0.?00
655.666666667 -> 600.000
3321.66666667 -> ).000
2256.33333333 -> 0.S00
383.666666667 -> 0.,00
1565.33333333 -> M.000

I suppose there's something wrong with glibc 2.3.1

Any ideas?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-15 09:35 UTC] sniper@php.net
It works fine here (glibc 2.1.3)
 [2003-01-15 12:35 UTC] iliaa@php.net
Works fine here to.
Do you have any locales exported?
 [2003-01-17 05:50 UTC] andrea at euronia dot it
The strange behaviour was related to a strange combination of gcc and glibc. Nothing was usefull (gcc and glibc recompilation). I had to compile gcc and glibc on another machine, copy binaries of gentoo emerge binary option system and all now is working fine.
It was a library problem.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 12:01:30 2024 UTC