[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Inconsistency: sometimes an integer, sometimes a float
From: |
Pascal J. Bourguignon |
Subject: |
Re: Inconsistency: sometimes an integer, sometimes a float |
Date: |
Thu, 23 Jan 2014 22:42:06 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
djc <peter.kaiser@gmail.com> writes:
> "(/ 536870911 1000000)" is an integer.
>
> "(/ 536870912 1000000)" is a float.
>
> I know why, but it's still unpleasant to have to program around it. I
> suppose this begs the question of when there will be a supported 64-bit
> release of Emacs.
>
> GNU Emacs 24.3.1 (i386-mingw-nt6.1.7601)
A 64-bit emacs wouldn't be a solution, you'd just increase the number of
cases where (/ (1+ n) p) is not of the same type as (/ n p).n
Instead, write:
(defun float/ (dividend divisor &rest divisors)
(apply (function /) (float dividend) divisor divisors))
and use it instead of /.
(float/ 536870911 1000000) --> 536.870911
(float/ 536870912 1000000) --> 536.870912
(float/ 536870.912 1000.000) --> 536.870912
--
__Pascal Bourguignon__
http://www.informatimago.com/
"Le mercure monte ? C'est le moment d'acheter !"
- Inconsistency: sometimes an integer, sometimes a float, djc, 2014/01/23
- Re: Inconsistency: sometimes an integer, sometimes a float, Rasmus, 2014/01/23
- Re: Inconsistency: sometimes an integer, sometimes a float, Nicolas Richard, 2014/01/23
- Re: Inconsistency: sometimes an integer, sometimes a float, Nicolas Richard, 2014/01/23
- Re: Inconsistency: sometimes an integer, sometimes a float, Eli Zaretskii, 2014/01/23
- Re: Inconsistency: sometimes an integer, sometimes a float,
Pascal J. Bourguignon <=
- RE: Inconsistency: sometimes an integer, sometimes a float, Doug Lewan, 2014/01/24
- Message not available
- Message not available