Re: div bug
Re: div bug
- Subject: Re: div bug
- From: "Mark J. Reed" <email@hidden>
- Date: Tue, 4 Aug 2009 16:46:22 -0400
Right. Note the same thing happening in C:
#include <stdio.h>
int main(int argc, char *argv[])
{
double n = 1.015 * 100 + 0.5;
printf("(int)n=%d\n", (int)n); /* 101 */
printf("(int)(float)n=%d\n", (int)(float)n); /* 102 */
}
The result of the arithmetic in double precision is
101.99999999999998578915. The difference between that and 102.0 is
too small to be represented in single precision (C "float", AS "small
real"), so when you demote the value before casting it to integer the
difference disappears.
On Tue, Aug 4, 2009 at 4:15 PM, Philip Aker<email@hidden> wrote:
> On 2009-08-04, at 13:02:46, julifos wrote:
>
>> Someone should write the rulez in the ASLG ;--)
>
> Meantime, selected portions of
> <http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf> should get you
> by.
>
>
> Philip Aker
> echo email@hidden@nl | tr a-z@. p-za-o.@
>
> Democracy: Two wolves and a sheep voting on lunch.
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
>
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden