• 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: Confused about floats
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Confused about floats


  • Subject: RE: Confused about floats
  • From: Shawn Bakhtiar <email@hidden>
  • Date: Tue, 5 Oct 2010 10:51:13 -0400
  • Importance: Normal

Also if x is a float, make sure you use the proper type cast, or values, ie  ( x = x + 120.00) or (x = y + (double)z , where x and y are double and z is an int).

Remember int, float, double, are C types, and typecasting rules should be in effect.



> From: email@hidden
> Date: Tue, 5 Oct 2010 09:27:31 -0400
> To: email@hidden
> Subject: Re: Confused about floats
>
> Amy Heavey wrote:
>
> > I've got two float values (x and y) that I'm using to change the
> > coordinates of a drawing action that is being looped through. I can
> > add a value to x and it draws the next image along, but I want to test
> > the value of x and if it is out of bounds I want to reset it to zero
> > and increase y, so I get a grid of images drawn.
> >
> > For some reason, even though I can do
> > x = x+128;
> > and it moves the image accross, x seems to be null so I can't test
> > against it, my if statement ' if (x > 300){' always fails.
> >
> > This must be something really simple I just can't see it this morning?
> > I'd appreciate any help.
>
> This doesn't make a whole lot of sense. There's no such thing as a null float value and you shouldn't need to be saying "x seems to be" any particular value given that you have a debugger and can actually examine the value.
>
> Frankly, my guess is that your problem is the second argument to the drawing method:
>
> > 	[img drawInRect:NSMakeRect(x,y,100,100)
> > 		  fromRect:NSMakeRect(x,y,100,100)
> > 		 operation:NSCompositeCopy
> > 		  fraction:1];
>
> Are you sure that the interesting part of each source image is offset within its whole internal coordinate space by the same amount as you intend to draw it into the destination. Or should that second argument perhaps be replaced by a rectangle whose origin is at (0,0)?
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
 		 	   		  _______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Confused about floats
      • From: Scott Ribe <email@hidden>
References: 
 >Re: Confused about floats (From: Gregory Weston <email@hidden>)

  • Prev by Date: Re: How to get selected text in a WebView
  • Next by Date: Re: Confused about floats
  • Previous by thread: Re: Confused about floats
  • Next by thread: Re: Confused about floats
  • Index(es):
    • Date
    • Thread