Decimal Flags?

Blitz3D Forums/Blitz3D Programming/Decimal Flags?

K(Posted 2012) [#1]
Okay... this may be a facepalm post. Sorry if it is. Looking through my code for a func needing modification I found a data system I had construsted before, only to reject because it didn't operate very fast. Decimal Flags, where each digit controls something.

If this has been done before, I'm stupid, if not, check it out...
112345 The first one is a placeholder to ensure that there are five digits to work with. The rest is, object 1, state 1 etc...

So, what's the big deal? Can't you just use binary flags for boolean tracking, and bytes for small things, offering 256 states? Well...
BYTE: 256 possibilities
BYTE,interpreted with DecFags:300possibilities

Yes. Yes I did the math. Why 300, not a power of 2 number? 300 is because the first digit can only be as high as 2 in a byte, giving us three states for it. The other two have ten, 0-9
3*10*10=300Total
When we get into four digit numbers, we must keep the first digit above 0, giving us nine states...
9*10*10*10=9000Total

Make sense? Am I dumb or is this useful? This encoding system( the way I built it) utilizes strin operations, so by necessity is slow. Its possible applications are for encrypting/packing files, and savegame routines, to maximize disk space. Of course, the max #of states for an element is 10. Thoughts? Reprimands? Head-shaking dis-appointment?
-K

Last edited 2012


Yasha(Posted 2012) [#2]
The other two have ten


No they don't. Bytes go up to 255. That means the second one has six, and the last one has ten or six depending on what the value of the digits preceding it is.

A word of any size can represent exactly the number of integers it can hold. There is absolutely no way for an eight-bit byte to represent three hundred unique values.

There are uses for decimal representation of numbers (look up Binary Coded Decimal to learn about them), but raising the information density of data is most definitely not one: decimal is in all circumstances less memory efficient than binary, on a binary-oriented machine.


K(Posted 2012) [#3]
Oh sorry, my bad, doing math as I type...err...3*6*(6 or 10)= 108 or 180

Ok, honestly that makes me glad, because it seemed illogical. I did all this scribbling on paper, went 'no, that's not right', debated,stared at it, and decided to post it here.

Verdict is that I am stupid. I thought I must be missing something. Thanks for telling me before I actually implemented (The horror). These funcs are actually an artifact from my period where I learned coding using no internet access/teaching, just the vanilla Blitz IDE (and a horrifying Atari emulator with 'AtariBasic'). Most of the code from that period has had to be trashed, as does this.
Thanks, Yasha.

I never will be a pro at this.

Last edited 2012


Yasha(Posted 2012) [#4]
Hey, having the idea required valuable out-of-the-box thinking skills. And there are uses for the technique... just not this particular expected use. Don't put yourself down over having an original idea.

Heaven knows it's not half as stupid as some of the things I come up with.