in reply to Re^4: Practical Example of Converting Packed Value
in thread Practical Example of Converting Packed Value
Is there any reason not to use these binary constants instead of hexadecimal constants in the real program?
One advantage of using hex/oct is that you can avoid having long, unreadable strings of bits in your code. The shortness of the masks and your use of "_" invalidates negates that advantage. It actually makes bin more readable.
Another advantage of using hex/oct for masks is that it allows you to interpret data in hex/oct dumps more easily.
Balance your need for readable raw data with your need for code readability and chose the one that suits you best. It's purely a judgment call.
I suppose in a real program, the binary/hexadecimal constants and the year 1980 would be symbolic constants
They're not going to change and their purpose is quite obvious based on the variable names. I don't think creating the seven symbolic constants would improve the code unless they are used in multiple locations.
|
|---|