> This is what I was talking about.... A better approach would be to use
> proper library transforms instead of type-casting...

Is what you are talking about is that the last few values in your printout
should be "4" instead of "-48"?  Perhaps if you took the bugs out of your
program, it would work better. "S[10] = '4';" is incorrect.  It's assigning '4'
to the 11th element of a 10 element array.  Try assigning it to S[0].

-- Keith Rollin
-- Palm OS Emulator engineer






Igor Mozolevsky <[EMAIL PROTECTED]> on 01/30/2001 05:57:05 PM

Please respond to "Palm Developer Forum" <[EMAIL PROTECTED]>

Sent by:  Igor Mozolevsky <[EMAIL PROTECTED]>


To:   "Palm Developer Forum" <[EMAIL PROTECTED]>
cc:    (Keith Rollin/US/PALM)
Subject:  Re: GCC Compiler Bug? (Or am I just losing my mind?)



At 17:11 30/01/2001 -0800, you wrote:
>Instead, this integral value of 4 is cast via (double) into a double
>value.  The
>string "s" is not converted!  Just the result of the expression (s[0] - '0').
>
>-- Keith Rollin
>-- Palm OS Emulator engineer

Incidentally,

#include <stdio.h>

char S[10];
char SS[10];
char SSS[10];

int main(void)
{

  S[10] = '4';

  memset(SSS, 0, 10);
  memset(SS, 0, 10);

  (unsigned int) (SS[0]) = (S[0]-'0');

  memcpy((void*)SSS, (void*)SS, sizeof(S[0]-'0'));


printf("sizeof(double):%d\nsizeof((S[0]-'0')):%d\nsizeof(char):%d\n",sizeof(double),sizeof((S[0]-'0')),sizeof(char));

  printf("%lf\n", (double)SSS[0]);
  printf("%lf\n", (double)(S[0]-'0'));
  printf("%d\n",(int)((double)(S[0]-'0')));
  return 0;
}
#gcc...
# ./a.out
sizeof(double):8
sizeof((S[0]-'0')):4
sizeof(char):1
-48.000000
-48.000000
-48
#

This is what I was talking about.... A better approach would be to use
proper library transforms instead of type-casting...

Igor M-)



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to