LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-16-2005, 06:02 AM   #1
rhoyerboat
Member
 
Registered: Feb 2005
Posts: 40

Rep: Reputation: 15
hex notation to a C compiler


okay, so, hex addresses to a C compiler, i see 0xc6 and 0xc60, although i cant get shake the thought that someone who should have been going 0x0000c6 or 0xc60000 was being lazy..
or it could also be that 0xc6 is 198d and 0xc60 is 3168d, the fact is that i just dont know, can someone point me in the right direction real quick?
 
Old 02-16-2005, 06:34 AM   #2
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Debian, FreeBSD
Posts: 1,450

Rep: Reputation: 48
I'm confused as to what you are asking.

There is nothing lazy about writing 0x23a instead of 0x00000023a.

Just like there is nothing lazy about writing 123 instead of 0000000000123. Leading zeros are meaningless.
 
Old 02-16-2005, 06:36 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,680

Rep: Reputation: 5893Reputation: 5893Reputation: 5893Reputation: 5893Reputation: 5893Reputation: 5893Reputation: 5893Reputation: 5893Reputation: 5893Reputation: 5893Reputation: 5893
AFAIK 0xc6 = 198d
 
Old 02-16-2005, 09:05 AM   #4
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Just like in decimal, trailing zeroes in a hex number are multipliers. In hex, each trailing zero happens to multiply the result by 16 decimal. Also, just like in decimal, leading zereos in a hex number mean absolutely nothing.

So yeah, here's what you've got:
0xc6 = 198d
0x0c6 = 198d
0xc60 = 3168d

Does that answer your question?
 
Old 02-16-2005, 09:12 AM   #5
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
Just as an aside, in C/C++ 0000000000123 would actually be an octal literal because of the leading 0, so it would be 83 decimal.

So in C/C++, 0123 != 123.

Last edited by deiussum; 02-16-2005 at 09:15 AM.
 
Old 02-16-2005, 09:42 AM   #6
rhoyerboat
Member
 
Registered: Feb 2005
Posts: 40

Original Poster
Rep: Reputation: 15
lol, thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
pointer notation vs array notation? pablowablo Programming 5 03-14-2005 12:34 PM
Is this a standard notation in inux? ray5_83 Linux - General 3 08-04-2004 07:15 AM
music notation software American Psycho Linux - Software 2 03-23-2004 09:49 PM
Music Notation software Micro420 Linux - Software 9 09-06-2003 03:29 PM
Scientific notation for C Chijtska Programming 4 02-19-2002 09:24 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration