help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting an Integer into Human Readable String


From: Thierry Volpiatto
Subject: Re: Converting an Integer into Human Readable String
Date: Fri, 08 Apr 2011 09:07:45 +0200
User-agent: Gnus/5.110016 (No Gnus v0.16) Emacs/23.3.50 (gnu/linux)

Klaus Straubinger <KSNetz@UseNet.ArcorNews.DE> writes:

> Thierry Volpiatto <thierry.volpiatto@gmail.com> wrote:
>
>> anything have a function for this:
>>
>> (anything-ff-human-size 4060)
>> ==> "4.0K"
>
> And there is url-pretty-length from url-util.el (which is part of GNU Emacs):
>
>     (url-pretty-length 4060)
>     ==> "3k"
>
> (In this example, the result is "3k" because 4060 is smaller than
> 4 * 1024.)
Note that all functions that use elisp to get such result fail with:

--8<---------------cut here---------------start------------->8---
(url-pretty-length 7141892608)
Debugger entered--Lisp error: (overflow-error "7141892608")
--8<---------------cut here---------------end--------------->8---

When using big numbers.
Same for format-mode-line etc...

To avoid that the calc functions can be used giving a string instead of
integer.

--8<---------------cut here---------------start------------->8---
(anything-ff-human-size "7141892608")
==> "6.7G"
(anything-ff-human-size (nth 7 (file-attributes 
"~/.VirtualBox/Machines/LoseDows.vdi")))
==> "6.7G"
--8<---------------cut here---------------end--------------->8---

Would be great elisp handle such numbers.

-- 
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]