freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use of FT_Long (= unsigned long) in psaux module


From: Tom Kacvinsky
Subject: Re: Use of FT_Long (= unsigned long) in psaux module
Date: Mon, 9 Oct 2000 08:38:26 -0400 (EDT)

> 
> > 
> > What is the perceived problem? Are you saying that a 64 bit box does not
> > adequately perform 32 bit calculations?
> 
> (FT_Long)(a << 24) | (FT_Long)(b << 16) | (FT_Long)(c << 8) | d
> 
> a, b, c, and d  are unsigned quantities.  Shifting an unsigned quantity
> left 24 bits and then casting it to FT_Long does not set the sign bit
> in the result, even if the sign bit is set (that is, 0x80 & quantity != 0)
> in the quantity being shifted.
> 
> This has to to with Type 1 charstring numbers encoded as FF X X X X.
> 

I just discovered that this is a compiler issue:  gcc 2.95.2 will do the
calculations and give back a number that is expected, but Compaq's C
compiler (that comes withs Tru64 UNIX 4.0F) does not.  Here is the test
code:

#include <stdlib.h>

int main () {

  unsigned char a = 0xFF, b = 0xFF, c = 0x00, d = 0x40 ;
  long result ;

  result = (long)(a << 24) | (long)(b << 16) | (long)(c << 8) | d ;

  printf ("%ld.\n", result);
  return (0);

}


The results of compiling this with gcc 2.95.2 and then running the
program:

-65472.

The results of compiling this with Compaq's C compiler and then
running the program:

4294901824.

Tom




reply via email to

[Prev in Thread] Current Thread [Next in Thread]