• 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: Strange issue when converting from hex to float
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange issue when converting from hex to float


  • Subject: Re: Strange issue when converting from hex to float
  • From: Sherm Pendley <email@hidden>
  • Date: Fri, 22 Jul 2005 13:30:19 -0400

On Jul 22, 2005, at 1:00 PM, Ian was here wrote:

I've tried all that before

Sherm-Pendleys-Computer:~ sherm$ cat testop.c #include <stdio.h> #include <stdlib.h>

    int main(int argc, char **argv) {
            long a = strtol("0xee", NULL, 16);

            float b = a/255L;
            float c = a/255.0;

            printf("a=%d, b=%f, c=%f\n", a, b, c);
    }
    Sherm-Pendleys-Computer:~ sherm$ gcc -o testop testop.c
    Sherm-Pendleys-Computer:~ sherm$ ./testop
    a=238, b=0.000000, c=0.933333

Clearly, your bug lies elsewhere, not in the division and assignment statement.

Double-check with the debugger and/or NSLog()s the values being passed to that. Also, double-check how you're printing your output. If you're printing the results later on, try checking it immediately after the division - it could be getting overwritten.

sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Strange issue when converting from hex to float
      • From: Ian was here <email@hidden>
References: 
 >Re: Strange issue when converting from hex to float (From: Ian was here <email@hidden>)

  • Prev by Date: Upgrade issues
  • Next by Date: Re: Starting out with adding Applescript support to my Cocoa app (basic question about the best script interface)
  • Previous by thread: Re: Strange issue when converting from hex to float
  • Next by thread: Re: Strange issue when converting from hex to float
  • Index(es):
    • Date
    • Thread