I was looking through an existing code in C wherein there is a check for no’s in a particular range 100 to 899. I wanted to add one more condition along with that the no can have the value 1FE. I should not convert it to a decimal no. But I need to check for this hexadecimal value.
My doubt here is, How will the hardware interpret the comparision of the decimal and the hexadecimal. The hardware will interpret the values in zero’s and one’s. So will it convert the decimal and hexadecimal no’s to binary to check the value ? (As 1FE when converted to decimal is 510 which will be included within the no 899).Please help to understand.
I was looking through an existing code in C wherein there is a check
Share
int x = 0x1fe;andint x = 510;are the exact same thing to the computer (or more specifically, to the compiler — the actual hardware will never see “0x1fe” or “510” — it will only see the binary version) so your question doesn’t make much sense.Changing the base only changes the representation of a value; it doesn’t change the actual value. If you have 1012 apples, and you have 510 apples, you still have the same amount of apples.
The representation computers use just happens to be binary. (Well, doesn’t ‘just happen’ to be, but…. yeah.)