Original Post
🔒 Locked
Smaller type
Advertisement
u could, or u could use a base 201 numbering system, convert it to decimal to store as an integer, then back again when u need it....though this would be probably a bit too complex for what u need...
according to my calculations u could fit four base 201 numbers into an 32-bit unsigned int... u could make a class like this...
according to my calculations u could fit four base 201 numbers into an 32-bit unsigned int... u could make a class like this...
class FourRecs
{
int rec;
public:
void setRecord(int number, int indexRec)
{
if (rec!=0)
{
rec %= (201^indexRec);
}
rec += (number * 201^indexRec);
}
int getRecord(int indexRec)
{
return (rec/(201^indexRec));
}
};
Storing 4 base 201 numbers into 32 bits is the same as storing 1 into 8 bits, and the latter is a lot less work. Go with 'char' type variables.
If you could get the former streaming, you would save space eventually, and it would add up if you are storing a lot of them, but I can't remeber how to stream arbitrary base numbers into bytes (if you figure it out, EMAIL ME PLEASE, I need it for a project of mine)
[edited by - Extrarius on March 21, 2003 1:03:49 AM]
If you could get the former streaming, you would save space eventually, and it would add up if you are storing a lot of them, but I can't remeber how to stream arbitrary base numbers into bytes (if you figure it out, EMAIL ME PLEASE, I need it for a project of mine)
[edited by - Extrarius on March 21, 2003 1:03:49 AM]
"..but I can''t remeber how to stream arbitrary base numbers into bytes.."
Sorry but I dont understand what you mean with that: Stream arbitrary base numbers into bytes? Can you explain me?
Thanks
"Those who follow the path of the warrior must be ready to die, to stand for their convictions, live for one´s convictions, die for one´s convictions"
Sorry but I dont understand what you mean with that: Stream arbitrary base numbers into bytes? Can you explain me?
Thanks
"Those who follow the path of the warrior must be ready to die, to stand for their convictions, live for one´s convictions, die for one´s convictions"
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement