hexadecimals

Programming, for all ages and all languages.
Post Reply
Adek336

hexadecimals

Post by Adek336 »

hi. As I've see in various posts, we, programmers prefer the 0xdeadbeef notation instead of 0deadbeefh. I like it more as well, but why is it so?? :) Both forms seem very similar. Or, perhaps you prefer the other notation?

Cheers,
Adrian
Curufir

Re:hexadecimals

Post by Curufir »

Probably something to do with reading from left to right. The 0xN notation lets you know that the next thing you read is a hexadecimal number, whereas with the Nh notation you read the number first, then find out it's a hexadecimal afterwards.

I suppose it would be kind of like having:

Code: Select all

foo, bar int;
Instead of:

Code: Select all

int foo, bar;
I know which one I prefer.

Or of course people might just like it better ;D.
Adek336

Re:hexadecimals

Post by Adek336 »

I think also the Nh notation was once popular under DOS and all the real mode stuff, for example all my books about bios interrupts use it. Something like indenting style perhaps ;D
Schol-R-LEA

Re:hexadecimals

Post by Schol-R-LEA »

I cannot speak for others, but I generally use the C style notation out of consistency: it is the notation used by C, and most of the languages influenced by it (C++, Java, Perl, etc.). It simply takes less mental effort to use one style consistently wherever possible.
srg

Re:hexadecimals

Post by srg »

I suppose it would be kind of like having:

Code: Select all

foo, bar int;
Instead of:

Code: Select all

int foo, bar;
Declaring variables in Pascal is

foo, bar :Integer;

But Hexadecimal notation in Pascal is

$N

Also VB has
Dim foo As Integer
Dim bar As Integer

and

&HN
Post Reply