Skip Menu |

This queue is for tickets about the Number-Format CPAN distribution.

Report information
The Basics
Id: 6147
Status: resolved
Priority: 0/
Queue: Number-Format

People
Owner: WRW [...] cpan.org
Requestors: frag [...] ripco.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: format_bytes() will not convert 1024 to 1K, etc.
format_bytes(1024) returns '1,024' not '1K'. Similar results occur for 1024*1024 ('1,024K', not '1M'), etc. This is because format_bytes uses ">" and not ">=" in its if conditions: i.e., because 1024 is not > 1024, it does not get formatted to units of K. The documentation is congruent with this behavior ("except that if the number is *over* 1024 [my emphasis], it will be divided by 1024 and "K" appended to the end") but that seems fairly counter-intuitive.
Date: Tue, 27 Apr 2004 11:57:46 -0700
From: William.Ward [...] bayview.com (William R Ward)
To: bug-Number-Format [...] rt.cpan.org
Subject: Re: [cpan #6147] format_bytes() will not convert 1024 to 1K, etc.
RT-Send-Cc:
Thanks for the feedback; you're right, and in fact someone already submitted a patch for fixing this. I've been planning a major overhaul since Number::Format conflicts with modern perls' locale support, but haven't gotten around to it. I'll try to get a new version out soon. Guest via RT writes: Show quoted text
> >This message about Number-Format was sent to you by guest <> via rt.cpan.org > >Full context and any attached attachments can be found at: ><URL: https://rt.cpan.org/Ticket/Display.html?id=6147 > > >format_bytes(1024) returns '1,024' not '1K'. >Similar results occur for 1024*1024 ('1,024K', not '1M'), etc. > >This is because format_bytes uses ">" and not ">=" in its if conditions: i.e., because 1024 is not > 1024, it does not get formatted to units of K. > >The documentation is congruent with this behavior ("except that if the number is *over* 1024 [my emphasis], it will be divided by 1024 and "K" appended to the end") but that seems fairly counter-intuitive.
-- William R. Ward william.ward@bayview.com President (650) 279-9904 Bay View Consulting Services, Inc. http://www.bayview.com/ ------------------------------------------------------------------------ Learn Perl in 8 hours! http://www.bayview.com/training/
Not an issue in recent versions of Number::Format