Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data types

Status
Not open for further replies.

SukiStrider

Programmer
Jun 26, 2002
8
Hey Everyone,

I am an originalist (Not sure if that's the right word for this or even if it exists), but
if I choose to get into something I like to know how every thing was done OR I cannot & will
never be satisfied with my own work no matter how good it is [genetics].

I was wondering does anyone know how to make your own data types, for example
I know you can rename 'C/C++' standard data type char, int, etc using typedef
to any other name you want, but I mean if I wanted to make an int data type that is 14 bits wide instead of 16 bits how would I do this?

Has anyone thought about how the inventor(s) of 'C/C++' made such a prominent data type.
I mean how do you tell the computer that the data type should have only this number
of bits or does it have something to do with the processor's register that is used when
coding the programming language?

If anyone can help you would be king/queen amongst men and woman.

Thanks in Advance
Jaigar©
 
Actually an int is 32 bits, not 16 (at least not since the DOS dark ages).

The only new data types you can make in C are structs (or classes in C++). Any other type of data would have to be done in Assembly (yuck!).

All computers I've ever seen are based on 8, 16, 32, 64 bits... So creating an int that isn't a multiple of 8 seems kind of useless since the other bits of the CPU register would be unused.
 
> but I mean if I wanted to make an int data type that is 14 bits wide instead of 16 bits how would I do this?
Code:
struct foo {
  unsigned int my14BitInt : 14;
};
Whether this is actually a good idea depends on what you want to use it for.

--
 
Thank you all very much...

As I said "king/queen amongst men and woman".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top