Why use hexadecimal constants?

后端 未结 11 976
挽巷
挽巷 2020-12-07 13:16

Sometimes I see Integer constants defined in hexadecimal, instead of decimal numbers. This is a small part I took from a GL10 class:

public static final int          


        
11条回答
  •  温柔的废话
    2020-12-07 13:52

    Ahh but 0xDECAFF is both prime (1460959), and a pleasent purple color (in RGB).

    For Colors hex is MUCH more convenient.

    FF FF FF is white 00 00 FF is blue FF 00 00 is red 00 FF 00 is green It's easy to see the color relationships as numbers (though the gamma and fidelity of the human eye tend to throw things off, but we'll ignore those inconvenient physical facts for pure mathamatical precision!

提交回复
热议问题