• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: div bug
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: div bug
      • From: "Mark J. Reed" <email@hidden>
References: 
 >Re: div bug (From: julifos <email@hidden>)
 >Re: div bug (From: Philip Aker <email@hidden>)

  • Prev by Date: Re: div bug
  • Next by Date: Re: div bug
  • Previous by thread: Re: div bug
  • Next by thread: Re: div bug
  • Index(es):
    • Date
    • Thread