Shorter and more consistent. Binary or base two system only allows zeros and ones, for example the number 255 in decimal system is equivalent to eight ones in the binary system. Hexadecimal numbers contain the digits 0 to 9 as well as the letters a to f, making it easier to deal with large decimal or binary numbers.
When working with numbers, it is important to understand the concept of narrowing; this happens when a variable of a smaller type is initialized with a larger type. As we store a smaller number in the larger memory space, we don't have to worry about data loss as the additional bytes in memory are filled with zeroes. Although these numbers are not truly random, they are based on some kind of mathematical formula. To generate random numbers, we can use the 'srand' (seed rand) function, which will give us two random values between one and six. To limit the range of this random number, we can use the formula shown onscreen; though this method is more complicated and not suitable for beginners, it is still a good way to learn how to generate random numbers - for example, to roll a dice.
Shorter and more consistent. Binary or base two system only allows zeros and ones, for example the number 255 in decimal system is equivalent to eight ones in the binary system. Hexadecimal numbers contain the digits 0 to 9 as well as the letters a to f, making it easier to deal with large decimal or binary numbers.
When working with numbers, it is important to understand the concept of narrowing; this happens when a variable of a smaller type is initialized with a larger type. As we store a smaller number in the larger memory space, we don't have to worry about data loss as the additional bytes in memory are filled with zeroes. Although these numbers are not truly random, they are based on some kind of mathematical formula. To generate random numbers, we can use the 'srand' (seed rand) function, which will give us two random values between one and six. To limit the range of this random number, we can use the formula shown onscreen; though this method is more complicated and not suitable for beginners, it is still a good way to learn how to generate random numbers - for example, to roll a dice.