Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.3.1

Bug #16148 Wrong int presentation in encode
Submitted: 2009-04-24 16:38 UTC
From: sash Assigned: tacker
Status: Closed Package: File_Bittorrent2 (version 1.3.0)
PHP Version: Irrelevant OS: Ubuntu intrepid
Roadmaps: 1.3.1    
Comments Add Comment Add patch

Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem : 14 + 20 = ?

 [2009-04-24 16:38 UTC] sash (Alexander Alexiev)
Description: ------------ File_Bittorrent2_Encode::encode uses round() for integers. round(1400000) returns 1.4E+6 which is invalid in bencode! Try changing the line return $this->encode_int(round($mixed)); to return $this->encode_int(sprintf('%d', round($mixed))); Test script: --------------- $e = new File_Bittorrent2_Encode(); echo $e->encode(1400000); Expected result: ---------------- i1400000e Actual result: -------------- i1.4E+6e


 [2009-04-24 16:52 UTC] tacker (Markus Tacker)
-Status: Open +Status: Verified -Assigned To: +Assigned To: tacker
 [2009-04-24 16:53 UTC] tacker (Markus Tacker)
-Roadmap Versions: +Roadmap Versions: 1.3.1
 [2009-04-24 21:56 UTC] sash (Alexander Alexiev)
More like "return $this->encode_int(sprintf('%.0f', round($mixed)));" so larger numbers can also be encoded correctly
 [2009-04-26 17:33 UTC] tacker (Markus Tacker)
-Status: Verified +Status: Closed
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at