Re: Strange issue when converting from hex to float
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