(Over?) Defensive Coding



  • Just in case $programmingLanguage changes its internal data representation (Snippet from source written/committed circa 2008)

    private int firstByteMask = (int) (1 << 15 | 1 << 14 | 1 << 13 | 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8);
    private int secondByteMask = 1 << 7 | 1 << 6 | 1 << 5 | 1 << 4 | 1 << 3 | 1 << 2 | 1 << 1 | 1;
    private int twelveBitMask = 1 << 11 | 1 << 10 | | 1 << 9 | 1 << 8 | 1 << 7 | 1 << 6 |
               1 << 5 | 1 << 4 | 1 << 3 | 1 << 2 | 1 << 1 | 1;
    private int fiveBitMask = 1 << 4 | 1 << 3 | 1 << 2 | 1 << 1 | 1;
    private int sixBitMask = (int) ( 1 << 5 | fiveBitMask);
    private int threeBitMask = 1 << 2 | 1 << 1 | 1;
    private int signMask = 1<<15;
    private int exponentMask = (1 << 7 | 1 << 6 | 1 << 5 | 1 << 4 | 1 << 3 | 1 << 2 | 1) << 7;
    private into mantissaMask = ( 1 << 6 | 1 << 5 | 1 << 4 | 1 << 3 | 1 << 2 | 1) << 16 | secondByteMask;

    I tried to recreate the spacing verbatim. I find it curious that the exponent and mantissa seem to be incomplete without "1 << 1" but I haven't analyzed how they're actually being used (however, I believe it likely that it was simply missed.) Also, these are instance variables, not "static final". Explicit casting?



  • @zelmak said:

    mantissa

    Incomplete Mantissa: The Unauthorized Biography


Log in to reply