Re: data types
- From: "santosh" <santosh.k83@xxxxxxxxx>
- Date: 3 Mar 2007 00:11:39 -0800
koolj96825@xxxxxxxxx wrote:
16-bit. It may be out of date.
Could be.
Yes, I think the manual was not kept up.
sizeof tells me there are 4 bytes to an int.
Then it's most probably a 32 bit object. What does sizeof(short)
indicate? Usually short is smaller than an int.
Anyway, now that I need to go back over and look closely at my code,
my question is: is there a way to declare a variable say a 16 bit
unsigned integer in C? Or is declaring it "short" the only specifier
that may work?
Why do you need an object of exactly N bits?
I have at least two issues where it matters. In one case, I created a
data type which is similar in concept to a bcd (binary coded decimal)
for working with degrees-minutes-seconds. I am wasting too much
memory per dms structure if they are 32-bit integers. I'll change it
to chars.
Are you trying to pack multiple values into an object? Is the runtime
environment really resource constrained? Unless you use thousands of
such objects, it may not be a significant saving, though of course I'm
speaking from ignorance of your system's limitations.
Next, I was using them as keys and since some quirk in the compiler
didn't let me use the constant for a max unsigned int, I made my own
constant.
Your compiler is either *really* old or broken or both. I strongly
suggest replacing it.
I also expected the number to "wrap around" at that value.
If it is equal to (2^n) - 1, where n is the number of value bits in
your object, then it should.
Another issue is that I used a bit vector to map out used numbers, as
a 16-bit key, an acceptably small amount of memory would be used up,
but a 32-bit value may be overboard especially since I don't expect
more than a few hundred keys to be in my data structure.
Have you considered a bitfield as an alternative?
<snip>
But unless you have a specific requirement, I suggest installing a
current compiler system. You have many choices for Windows, though I
recommend either a version of gcc, (Cygwin or MinGW), or Visual Studio
Express.
I only program on the hobby level, although I am doing this project
for my office, I thus have no budget.
Both the compilers I mentioned are free to download and use, (though
Microsoft's Visual Studio Express has an onerous EULA). gcc is
absolutely free, available for just about every platform, has very
decent C99 support and is totally free to use. It's a world class
compiler. Most regulars here will recommend gcc to you.
Beware though that gcc by itself doesn't include the standard C
library. However your operating system should include a C library,
which gcc can use.
.
- Follow-Ups:
- Re: data types
- From: bluejack
- Re: data types
- From: koolj96825
- Re: data types
- References:
- data types
- From: koolj96825
- Re: data types
- From: santosh
- Re: data types
- From: koolj96825
- data types
- Prev by Date: Re: porting vs migrating
- Next by Date: Re: How To Implement Timer in C
- Previous by thread: Re: data types
- Next by thread: Re: data types
- Index(es):
Relevant Pages
|
|