FileDocCategorySizeDatePackage
CastTest.javaAPI DocExample571Sun Mar 28 19:05:24 BST 1999None

CastTest

public class CastTest extends Object

Fields Summary
Constructors Summary
Methods Summary
static intfakeCast(int intValue)

  
    int byteValue;
    int temp = intValue % 256;
    if ( intValue < 0) {
      byteValue =  temp < -128 ? 256 + temp : temp;        
    }
    else {
     byteValue =  temp > 127 ? temp - 256 : temp;
    }

    return byteValue;
  
public static voidmain(java.lang.String[] args)

    for (int i = -512; i <= 512; i++) {
      byte castByte = (byte) i;
      if (fakeCast(i) != castByte) {
        System.out.println(i + "\t" + castByte + "\t" + fakeCast(i));
      }
    }