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