Malest a vegetarian day is almost here!

Tomorrow is the “International Hug a Vegetarian Day” as purported by PETA. The wonderful and oh so marry organization behind the civil rights for animals and retraction of concern for humanity. How much more arrogant and self righteous can one be then to create a holiday for one’s self? How about I make an “International Beat Your Kids Relentlessly Day”…

“Who doesn’t love “Hug a Vegetarian” Day? It’s always a smashing success with tens of thousands of people taking part around the world. Check out some photos here if you don’t believe that vegetarians make better huggers!”

It’s a smashing success? I’ve only heard of it just 10 minutes ago God damn it. And I get your sweet little quip, but how smug are you to say that vegetarians make better huggers. Just like they make better lovers, members of society, and all that other hub bub you shove around in your propaganda about how awesome you are for not eating meat. I’m sorry honey, but you shit smells just as foul as mine does. I just take pride in my farts! This viral epidemic of elitism and self worship through the entity of defenseless creatures is mind boggling to me. Of all the things in the world I hate and dislike, this for some reason is the one at the top of my list that I want to rip from the face of this planet like the plague it is.

Human’s weren’t supposed to eat meat.

Yeah, I’ve heard this debate. And it makes me cringe. A very long time ago when we were still in trees climbing around and being the little monkeys we were. We evolved some very unique processes to survive. We were prey, we ate leaves and fruits, and had many threats in the world. We needed a defense mechanism, all the other mammals were developing heightened sight and senses to see where enemies were for themselves. They decided to be self sufficient. The primemate on the other hand went a very bizarre route, it utilized a small unexploited process of the animal kingdom.

Social Nets

Yep, we decided to instead become extremely social animals. Instead of basic small social nets of a mother and children like most animals. And even more complex then packs like that of wolves. We went a lot further and formed large groups of primemates, we didn’t have to be related or anything. We just grouped up, and most primemates today still use this for protection. This wasn’t to be “happy”, happiness as an emotion and all the other complex emotions we developed were a result of this decission. We were in much larger groups so that way there were more eyes and ears to pay attention for danger. But we had to trust one another, to keep the group strong and large. So it became necessary to recognize each other. Our brains began growing and our eyes began reacting more to different colours and complex images. We needed to be able to recognize one another and be able to store a memory of each individual. No longer are we en masse, we could easily distinguish our brother from our cousin.

This process developed for years and several species related to us ran with it and grew more complex. Hence the massive social networks of nearly all primemate species. They groom and communicate with each other. They hug and sleep next to each other. They grow extremely attatched to one another all for the sake of protection and survival. But one species of all of these, us, the pre human, human. They took it further. This increase in brain size allowed them to learn about tools. We no longer had to evolve growths on our bodies to perform tasks. Becoming a predator was no longer an evolutionary step of growing the teeth and claws needed. We just had to build the tool to make it. And we exploited this massively. We invented fire, and sharp weapons. Overnight we could now become predators. Using our social networks we were able to get into large groups and overnight have the powerful hunting senses of other predators. We put this all together and were able to start taking down other animals for consumption.

We were still relatively dumb, and putting ourselves into these hunting situations put our lives at risk. We needed more protection, so evolution stepped in. Instead of evolving different attack and defense body parts. We put all our evolution power into the one thing that granted us this amazing power to think and create tools. Our brain. We wanted a complex strong brain, and with that we could protect ourselves by building defense items instead of growing them. This takes work though, lots of work. See the brain consumes the most energy in our body, it is so hungry for energy that it even consumes it in our sleep when most of the rest of our body shuts down. There’s other parts that consume large quantities of energy as well. The heart, the lungs, and the digestive track. Well we need our heart, we can’t take energy from that… it’s how we push energy around our body. And we certainly need our lungs, with out that we don’t have the oxygen to burn in processing sugars and proteins. This left one other thing, the digestive track, now this we could probably make much more efficient with the correct adjustments.

Food is hard to eat

It’s hard to eat. The body spends a lot of the energy it gets from food just to digest new food. You want to hear the most surprising part. It’s very hard to digest vegetation. Plants are tough little things, and don’t like to be broken up. Most herbivores have very complex digestive systems to consume plant life and be able to survive off the nutrients in it. The bovine has grown such a complex system that it can actually extract more energy from grass then it takes to digest it. It took multiple stomachs and symbiocis with countless number of bacterium. In all actuality the bovine (or cow) isn’t a herbivore. Instead it’s a farmer. It has several eco systems that it maintains inside its body as stomachs. In these stomachs they grow large amounts of bascterium, which they feed large quantities of grass. The bacterium in turn consume the grass, split, and grow larger populations. The cow then finally pushes all these bacterium through their intestine and absorb the carbs and proteins from the bacteria. In turn they are actually eating the bacteria

We had a complex digestive track to digest plants as well. Nothing as awesome as the grazers of the Earth, but instead it was big and cost a lot of energy. We had this meat though, it was slightly easier to digest because it contained far more energy in smaller quantities. Now read that again, I didn’t say that it isn’t hard to digest, yes the meat does have the downside of rotting in our gut sometimes, but the amount of energy is far greater in meat then in vegetables. We could eat smaller quantities of food and get the same amount of energy as before. Fire to the rescue. By cutting up meat and burning it, the meat was slightly digested before we ate it. This removed some of the nutrients in the meat, but it was still high quantity and it was predigested for us with 0 energy use. We started eating cooked food to make it easier on our digestive track to eat!

Now with our eating problem made efficient, we can now as a species reduce the energy cost of our digestive track and in turn send all this extra energy to the growth of the brain. Our bodies actually evolved to consume meat, we are supposed to!

That just leaves your moral decission to eat meat. And if you don’t want to, don’t. I don’t care. But you assholes who try saying I’m a horrible human being for eating meat can lick my balls. Further more jokes like this holiday tomorrow… they can rot in hell!

Where are the Software Spiders to eat Software Bugs?

Bugs in videogames are sometimes a nuisance, but others are interesting and even whimsical. Who can forget bugs like that found in the original Super Mario Bros. that allowed you to clock in as many free lives as you wished, as long as you exploited the bug effectively. Or think of the number of bugs programmers left in a game because they thought it was interesting and instead turned it into a feature instead of a bug, merely by considering it a feature instead of a bug.

Bugs are different then errors. An error is specific kind of bug that is common and you can see it coming from a mile away if you can read the syntax of the code. An error is merely a program crashing because the code doesn’t work. It is considered a kind of bug, but these aren’t the bugs we are referring to. The bug I’m referring to is the bug that is hiding, it is code doing something unnexpected, or one part of a program that on its own functions properly, but has adverse effects when coupled with a different part of the program.

Think about if you programmed a collision detection system. One part of it checks collision against circles and keeps a physical object from penetrating it. Another part of it checks collision against a square object and keeps a physical object from penetrating it. Now we put the round object and the square object next to each other and we move the physical object so that it collides with the round object, it then pushes said object into the square object, which then pushes it back into the round object. Now lets include a force controller that allows us to move said physical object, on its own it functions properly, when you collide with one object it works properly, but when it is placed in the scenario of colliding between these two objects it fails and your physical object now is stuck being pushed back and forth between the two collidable objects.

This is a bug. Each component of the game works fine on its own. They work in simple combinations of eachother. But once you start making the situation more complex it fails. Just be looking at the code it might not be evident, with out the genius mind of some engineer perceiving every possible scenario these two engines would be put in, and every line of code that the two engines would have to come up against, there is no way to really see this outcome with out debugging.

This is the process that a game tester goes through. They play the game afterward and try every bizarre scenario they can think of in the game and try to break it. Then record what occured, where it occured and why they think it may have occured. The programmer then goes in and with this information about the scenario that broke the engines, they can alter the code to compensate, or remove the scenario from the game and make it known that this type of situation can not occur! Level designers then know not to allow this type of placement of objects in the level. This option is often not the answer we want, as it my be a key part to gameplay, or in worst situations the world is dynamic and there is no way to stop the player from moving objects into this situation.

Backup a second

Rewind your clocks, step into the past, lets go retro. In the eighties when I started gaming, videogames themselves were very basic toys. You had a small onset of rules, and you were tossed into a repetitive world where you used these tools to progress. Pac-man had 3 basic rules: eat pills, avoid ghosts, if eat super-pill chase ghosts. The game was then just a series of small mazes in which you consumed all the pills. It was simple, it was fun, and there wasn’t much wiggle room.

Games have progressed massively since the likes of Pac-man, Gallaga, Pong, and the sort. We’ve gone 3D with massive maps and hundreds of Non-playable, AI controlled, characters. Instead of just a directional stick, there can be 5, 10, or more buttons and combos of buttons to perform actions. Along with menus and other interfaces to gain even more actions.

When testing an older game the rules in one level barely change from the next level. Level 50 in Pac-man is no different from Level 1 except that in the map is different. It follows all the same rules. Testing the difference between two is very basic. You don’t have to aggressively test the collision detection between Pac-man and the ghosts on level 50 like you did on level 1, the map didn’t change anything about the collision detection of the two MOBs. Instead you are merely making sure the wall collision is up to task. In all actuality you could make Pac-man 1000 levels in length and barely have to test anything past the first 10. 3 guys in a room could design, program, and test this game in a matter of weeks and have a bug free application out the door 99.9% sure nothing is wrong with their product.

But lets consider Metal Gear Solid 4. Each level is massively different, and introduces new things to the system that it hadn’t had to deal with before. Last level had water rippling in a lake while Snake walked through it, but this time it’s grass waving and getting squashed under his feet. Last level had squat enemies with rifles, this level has tall enemies with grenades. The game is far more complex, and as the complexity increases the number of possile combinations of engines and code that occur increases as well.

Lets look back at Pac-man, lets flesh out the basic components of gameplay:

  • Movement of Pac-man and force controller
  • Movement of ghosts and their AI
  • Path boundaries/wall collision
  • Power Pill
  • regular pill consumption
  • map design – the only truly variable part of the game, everything else is static

With the map being the only variable in the game, and the rest being static. The number of scenarios that arise is congruent to the number of levels you design by a power of only 1. So 100 levels means only 100 scenarios to check.

But when you take Metal Gear Solid 4 the number of variable scenarios increases. Each map doesn’t function the same, there isn’t only one kind of wall, or one kind of door. There isn’t one kind of enemy, or one kind of background. The variances grow exponentially, and just in a matter of 2 levels you could have thousands of variances.

And every variance has to be foreseen, checked, and tested. It takes tons of people to do this, and months of game testing. Some of the testing can’t even be tested easily because it could have something to do with AI, and you don’t have direct control over what choices the AI is going to do. What if when this type of MOB enters this doorway at a certain angle with shooting his gun he clips into the wall and the collision detection gets him stuck there. How do you lure said enemy into the doorway and shoot his gun at the same time just to test if this bug will occur? Nevermind how could you expect to foresee that one coming and actually think to take the time to test this possibility!?

This can take months of playing the game non-stop and would put the budget and calendar restraint of the game this side of never. The game wouldn’t make it out the door and into your hands if we spent all our time digging out every bug. So we release the game in hopes that we’ve located most of them and that the game doesn’t crash anywhere. If in the wild a customer locates a bug and reports it, or if we find a bug in it ourselves, we will make a patch to fix this error.

It’s one of the downsides to complex structures. It is difficult to comprehend all the possibilities when the structure is so large. Think of it as this, you have a car traveling down the road. You just left 5th avenue on Manhattan island and you are heading to Coney island. How many paths can you take to get there? The shortest and simplest path can be relatively obvious, or a handful of best paths. But what if someone who has never been to New York tried doing this with out stopping for directions? Do you the reader even know that Coney island is to the south east of 5th avenue on Manhattan? With out even knowing a general heading you could end up driving thousands of miles around long island trying to get to your destination. It is nearly impossible to phathom all the possibilities one might take… including if they can backtrack on themselves.

Well apply that to a videogame. The same thing applies. Pac-man is like driving down mainstreet in a small town like Albany Georgia, while Metal Gear Solid 4 is like driving through the entire state of California!

Wrap it up
I like to think of the world created in a videogame is its own unique world with its own unique rules. They don’t follow the rules of Physics we follow in the real world. A lot of bugs aren’t actually bugs, but instead an anomoly in the rules stated by the laws of the world. The universe did not define the rules of life, instead it defined the rules of physics and quantum physics. How atoms will interact on a basic level. Those basic rules when put into combination result in molecules, those molecules in combination result in compounds and structures, tie in some gravity, light, and infinite number of scenarios and those compounds start to incorporate themselves with each other until finally one day the compound stands up and says to its self “hey I’m alive”.

Now of course a videogames world is no where near that awesome or complex. But we’re only human and a PC is only a computer. It has limitations, but the concept is there. A ball doesn’t bounce in a game because we say it should bounce. It bounces because we assign the ball a shape (sphere) and give it elasticity, and then force it towards another surface.

These supposed bugs occur and your left with an annoyance. But who says it’s a bug? Say you bounce a ball in the real world, it flies into the air toward a basketball hoop and gets stuck between the hoop and the backboard and wedged in so it can’t move. Is that a bug? Didn’t the amazing program of our universe just break? Nope, that is a normal outcome of the system designed, if this ruins your possibility to finish your game of basketball with your friends, that’s no bug, that’s just a unforeseen outcome.

Floating under the weight of an integer – Part 2

Errors are my way

This is a follow up to Part 1 of “Floating under the weight of an integer”. This article will assume you have read that article, or know something about converting decimal values to binary values. If you need a refresher return to: Floating under the weight of an an integer – Part 1.

In the previous article I described how computer systems store decimal values in binary notation.

History of Number Systems
We humans developed the Decimal Notation systems a couple thousand years ago. The numeral system we use today was originally devised by the wonderful math freaks over in India and brought to the west through the middle east on trading routes (so history assumes). Before the current system we had several other systems of counting which included:

  • Roman Numerals – most Americans and Europeans learn these in primary school
  • Greek Numerals – very similar to Roman Numerals, the symbols differ slightly
  • Babylonian Numerals – The Babylonians utilized a base 60 system… it consisted of 59 symbols, but no zero because the mathematical concept of zero had yet to be discovered

There are others as well. Do note, the earlier numeral systems we used in the west functioned very poorly in math. Take Roman Numerals, addition was relatively simple:

V + I = VI
V – I = IV

some problems arose:

X – III = VII

It makes sense true, but visually and literally it doesn’t follow any valuable pattern. This is because how the numerals were written didn’t follow a robust mathematical system. The Babylonians were the only ones who concidered using a base system, but the system was so grotesquely massive (base 60) it is rather hard to even understand how higher level math could be written with out looking like a massive splotch of ink! To me it reminds me of someone obsessed with circles or something, but wasn’t it the greeks who invented the 360 degree circle?

It goes to show you though, a value can be written any number of ways. Our choice to use the symbols 0 -> 9 is completely arbitrary, and is debated at length as to the origin of the truth. I personally consider the hand debate makes the most sense. We have 10 fingers, so we are used to a base 10 system. We can conceptualize powers of ten easily. Possibly also the reason why our naming system is based on a base ten system. Keep in mind, the name of the value roots more in the way we perceive the value then it has to do with the value all together. twenty one is as arbitrary as “vinentu

ten = 10 (decimal) = X (roman) = 1010 (binary) = A (hexidecimal) = 12 (octal)

Well, computers don’t have 10 fingers. Computers have two. Well, they don’t have fingers, but they have registers that can be on or off… which can be related to two. Binary made the most logical sense when designing the computer. Also because adding binary values is extremely simple.

101 + 10 = 111

note how the bits just fall into place. If a 1 already exists in it’s place the one get’s pushed to the left. In subtraction to the right. For a child who never seen the values from 2 to 9 would probably find this arithmetic a million times easier then base 10 math. No need to remember that 3 and 5 is 8. You just remember 0 and 0 is 0, 1 and 0 is 1, and 1 and 1 is 10.

Significant Values

In the previous article I also described the storage technique of the Double Precission 64-bit Floating Point Value in computers. In it I showed how the 64-bit register is broken into 3 important sections: sign, exponent, mantissa/fraction.

The significant value stored in the mantissa is only 52 bits in length. Which results in approximately 16 significant decimal values. This level of significance along with translating repeating values in binary or decimal creates many arithmetic errors when performing float math. Most of these errors are so small that it is nearly insignificant, but at times the error is horribly bad. The most horrible is usually a result of the number of significant values that can be stored.

Anyone who has taken a science course that deals with any math, you have probably heard of significant values. You may have also seen it in a Statistics course, or for you great math nerds… you’ve learned in any of your courses.

Numerical values sometimes have what are called insignificant values. We see this often in the description of population. It is commonly stated that the world population is 6.6 billion. But we all know there is no way that we have exactly 6,600,000,000 people on earth. That is such a bizarrely round number of people to have. The population is more like 6,602,224,175 (July 2007 estimate). The number is so large though that we aren’t concerned about every individual, instead we describe it as an estimate in scientific notation.

Usually in science and statistics we reduce the number of significant values to 3 or 4. It makes the value much easier to read and understand. The value PI isn’t usually written as the infinite string it is, but instead as 3.1415. Or when measuring the length of something we can’t recognize the exact specific length, instead we assume the closest sig value. The table is 1.5 meters long… not 1.50000000000000000000001 meters long!

We limit the number of significant figures for several reasons.

  • The exact value is not that significant – 1.50000000000000000000001 as opposed to 1.5
  • The value is uncomfortable to read – 6,602,224,175 as opposed to 6.6 billion
  • It isn’t humanly possible to record the exact value – such as measuring the distance from the earth to sun
  • The value is so large that it is inconceivable at an exact value – such as the distance across the Milky Way galaxy
  • The container in which we store the value can not handle the size of the value – such as in the case of computers

The latter of these reasons is the area we are concerned when it comes to programming a computer. Reducing significant values reduces the accuracy of the result. Sometimes the accuracy can be spared, but in a situation where accuracy is needed we want as many significant values as possible. Infinite would be a dream, but in a computer you do not have infinite amounts of space. It is a physical machine, thusly it has physical constraints.

The average computer runs as a series of 32-bit registers in binary. The average modern processor has 2MB of cache. That is 16777216 bits to store 1s or 0s. In theory we can only store a value in binary with a sig value length of 16777216. That sounds like a lot. But again that’s just theory, and in actuality that cache needs to store a lot more then just one unsigned value.

A Double Precission 64-bit Floating Point Value can store 53 significant values (52 bits plus an assumed leading 1). In my last article I showed some basic code that described this problem. Here it is again:

In a flash actionpanel (or in any language with a double precission float) type the following code:

——-
var num:Number = 98765432109876543210;
trace(num);

the console should output:

98765432109876540000
——-

Let’s continue this on to show the amount of error it can cause in fractional values:

——-
var num:Number = 10000000000000000.999999999;
trace(num);

the console should say:

10000000000000000
——-

We lost all that decimal information! This is a problem. If we took the value 100000000000000000 and continually added 1 to it, the value would never change:

——-
var num:Number = 100000000000000000;

for (var i:int = 0; i < 10; i++) { num++; trace(num); } ------- The 1 added on to 100000000000000000 is outside of the significant value range. It gets chopped off each time the arithmetic occurs! This is one problem with how significant values can effect you. Now you might think the difference bettwen 100000000000000001 and 100000000000000000 is so significant it wouldn't matter. But if we added 1 to this for over and over 100000000000000000 times... we should get 200000000000000000. The difference of which is very significant. This is the kind of error we have to except when dealing with Double Precission Floats. Of course though, it isn't often we deal with extremely large numbers and extremely small values at the same time. Floats are great for this. As long as the values you are performing arithmetic on are in the same range as each other, floats perform fantastically well at representing extremely small and large values. You just can't mix and match 40 quintilian with the fraction 4 billionths. Repeating values make me cry
Significant values aren’t the only problems when dealing with floats. Decimal to Binary conversion can cause several errors as well.

Most of us are used to repeating values in decimal notation. 1/3 isn’t so pretty written in decimal notation, .3333333333~. Not so pretty is it? This value has an infinite number of significant values, and thusly must be reduced if we want to store it in a float. But why is it repeating? We understand why irrational values like “PI” and “e” repeat, they are irrational, there is no fractional or rational value that we can state to represent their value. “Pi” is the ratio of a circles circumfrence to its diameter, c/d. But c nore d has no whole integer values to represent them. 1/3 does, 1 and 3. What makes this repeating value so significant? It merely has to do with the decimal system we are writing it in.

There is no congruency between 3 and 10. There are no multiples of 3 that are equal to a power of 10. For instance:

1/4 == 25 / 100

the multiple of 25 and 4 is equal to 10^2.

There is no multiple of 3 that is equal to 10^n (when considering only whole integer values). This is merely as a result of the base 10 system we are in. Repeating values in Decimal sometimes don’t have repeating values in Binary, and vice versa, there are non-repeating values in decimal that are repeating in Binary.

Take for instance the value .9 or 9/10, in binary we get .111001110011100~. Same goes with .1 or 1/10, in binary .000111001110011100~. In Binary repeating values are actually far more abundant when converting from decimal. Why might someone ask? Well think about it, 1/2 is the shortest binary fraction. This 5/10 in decimal. We need some exponent of 5/10 to occur in the value somewhere to stop the repeating value (basically, it’s a bit more then just that).

Repeating values have to be truncated to fit into the 52 bits of significant values a Double can store. This turns the value into an estimate and is no longer accurate. When converting it back to decimal notation the value can sometimes change slightly due to this innaccuracy. This is whay you will see small fractions of error when performing arithemetic processes with fractional values:

—–
var num = 0;

for (var i:int = 0; i<50; i++) { num += .1; trace(num); } ----- Note what the console outputs. Several times you get values of .999999999 leading out of the value. Leaving an error of .000000000000001. This is extremely common and you should just get used to it when dealing with decimal fractions. There are ways around it, strip long decimals to a significant value of your choice. Or you can turn all fractional values into whole integer values first, but this still doesn't work in the case of values like 1/3 which repeat in decimal as well.

Floating under the weight of an integer – Part 1

Converting Decimal Values

Some people know what a float is, others don’t. Some know that floats have issues when performing arithmetic, others don’t. A lot don’t know why these issues occur, just that they do, and that’s what I want to talk about today.

Floating Point Number, otherwise known as a float is a way of storing extremely large values and decimal values on a highly integer based system like a computer. There are several different algorithms for it, the two most common are the Single Precission 32-bit Floating Point Value, and the Double Precission 64-bit Floating Point Value. Most of my tech threads happen to be about flash right now, and I hang out at a lot of Actionsciprt forums, so I am going to describe the Double in this discussion because that is the type of float Flash has used for years.

A double float is stored in a 64-bit register value. The 64 bits are broken into 3 major sections to describe a value in scientific notation:

sign –
the first leading bit denotes if the value is positive or negative, 0 is positive, 1 is negative.

exponent –
the next 11 bits denotes the length of the value for scientific notation. The 11 bits result in values from 0 to 2047, but we know we need negative values to create fractions less then 1 (or the misnomer decimal values). This value actually represents a value from -1022 – 1023 by subtracting 1023 from the value shown. the values 0 and 2047 a saved to represent +/-infanity, NaN and zero. Mainly because none of them can be reprsented as a value greater then 1 raised to any value. Why greater then 1? Well that has to do with the mantissa.

mantissa / fraction –
the last 52 bits represent the significant value.

Different floating algorithms use different ways of storing the mantissa or ‘significand’. In double floating point it is stored as a binary fractional value resulting in actually 53 implicit bits of significance. A binary value greater then or equal to 1 always has a leading 1, no matter what. So we shave this 1 off, and store the rest as the mantissa.

This results in log(2^53) = 15.955 or approximately 16 decimal significant values. Notice whenever you write a double float you can only store a significant string up to 16 digits long. Let’s test that out.

In a flash actionpanel (or in any language with a double precission float) type the following code:

var num:Number = 98765432109876543210;
trace(num);

the console should output:

98765432109876540000

note 3210 was cut off resulting in 16 significant values. Due to the conversions of decimal values to binary values, and rounding algorithms in the conversion, some numbers will get 17 significant values, and others sometimes 15 significant values:

var num:Number = 12345678901234567890;
trace(num);

will yield 17 sig values:

12345678901234567000

So let’s get into the math of this whole process for why errors come flying out every which way during float arithmetic.

Decimal to Binary conversion

Computers store values in registers. Registers have an on or off state. This is only two states, so we store values in binary notation to quickly store values. This means the register has only two symbols to its disposal, 1 and 0. No positive, no negative, no point, nothing but 1 and 0. So the simplest and easiest storage method is the unsigned integer.

Binary works just like decimal notation. Not decimal values like they taught you in school, as I said this is a misnomer. Decimal does not mean fractional, decimal literally means “proceeding by tens”. Hence the prefix ‘deci’ which means tenths. For you Europeans think decimeter or dekameter.

In decimal notation we have 10 symbols: 0123456789. These are then used to represent a value by adding up these values multiplied by it’s ‘place’ in the number. For instance:

125 == 1 * hundreds place + 2 * tens place + 5 * ones place == 1 * 10^2 + 1 * 10^1 + 1 * 10^0

Binary works the same, but the places are of base 2. So it goes that:

101 == 1 * fours place + 0 * twos place + 1 * ones place == 1 * 2^2 + 0 * 2^1 + 1 * 2^0

So to convert a decimal value to binary is very simple. In very human terms the basics are as follows.

122

convert by finding the highest possible power of two that goes into the value once. Write down a 1 and subtract the exponent from the decimal value. Now reduce the exponent to the next lowest power (2^(n-1)). If it is divisible, write down another 1 and subtract, if not, write down a zero, and then reduce the exponent again. Do this until you’ve done all exponents from n to 0.

122 -> 64 || 2^6 == 1
58 -> 32 || 2^5 == 11
26 -> 16 || 2^4 == 111
10 -> 8 || 2^3 == 1111
2 -> 4 || 2^2 == 11110
2 -> 2 || 2^1 == 111101
0 -> 1 || 2^0 == 1111010

122 decimal == 1111010 binary

How about decimal values? Let’s look at this process in more human/lamen terms for the sake of ease. First we scrap the sign and store that at the front of the double float, now we have an unsigned value. Next we split the decimal into two parts, values greater 1, and values less then 1. Basically splitting it at the decimal point.

12.5 -> 12 and 5

we convert the none fraction like before
12 -> 8 == 1
4 -> 4 == 11
0 -> 2 == 110
1 -> 1 == 1100

converting the fraction is a little different. To tell you the truth I don’t know what the heck the computer does to convert it… but for your sake as a person to understand how they are equal let’s go through a basic algorithm for finding it.

It’s pretty simple. Multiply the faction by 2, and write down any whole value on the left of the decimal point. There can only be a 1 or a 0, no other value will result. Drop off that leading whole number and continue through it.

.5 * 2 = 1.0 == .1 in binary

for a better representation how about converting .625.

.625 * 2 = 1.25 == .1
.25 * 2 = 0.5 == .10
.5 * 2 = 1 == .101

.625 decimal == .101 binary

Fractional Binary to Double Float

So now we have our value 12.5 in fractional binary 1100.1

To make it a float we normalize the value, this means we convert it to scientific notation.

1100.1 == 1.1001e+3

The exponential value has 1111111111 added to it and then is placed into the 11 bits for the exponent, and then we shave off the leading whole number 1 and store the fractional value as the mantissa.

the float now looks like this:

0 10000000010 0000000000000000000000000000000000000000000000001001

to make it easier on the eyes, in hex:

0x4020 0000 0000 0009

Wasn’t that fun?

Forum etiquette is at a loss

There is no right way to ask a question in a forum, but there is definitely a wrong way. Your teacher lied to you, there are bad questions! And I am here to explain why.

I communicate through several different forums on the internet, and my general purpose is to give tech assistance as it is my favourite topic. Math, programming, videogame console repair, gadgets, etc. I see questions all the time, sometimes I know the answer, others I don’t. Some I don’t even know what the person was even asking.

In one day I’ll say one of the following about 10 times:

  • I don’t know what you are asking.
  • Can you rephrase your question?
  • Can you indulge us with some more information.
  • Holy God, am I supposed to have an interpreter on hand?

If you want your question answered, maybe try and give a little more help in locating that answer. I understand, you may be in the dark completely and don’t even know what information to give. And that is a huge dilemma. But any info is good, supply some source material, a drawing to describe and visual thing you are asking about, or just the blatant straight forward facts you have. Avoid speculation for more then a sentence or two and just stick to your question. And most importantly, your question should most likely by more then 5 words long! And foremost, GOOGLE your question first!

Here are some examples of bad questions:

– I got this error saying something about null reference… what is wrong?

Where is this error occuring? What line of code is it on? What is the corresponding line of code? What language are you in? Lets get the obvious out of the way… What does the error even SAY!?

– My Sega is broken, I can’t play any games and I really want to play Sonic!

I don’t care what game you want to play. How about the console that is broken, Sega has several consoles, all of which have a Sonic title. What happens when you turn it on? Does it even turn on? What have you tried to remedy the situation?

– What is a vector in math?

Have you tried google?

– I have this problem and its causing issues, and I can’t figure it out. The last time this happened I just restarted the my computer and it fixed it, but I don’t like that. Every time this happen I have to wait 25 minutes to get back to doing what I was doing. OH MY GOD, again while writing this it happened! PLEASE HELP ME!

What!? Do I even have to say?

My favourite answer… yes you asked such an idiotic question you get to now look at my ass!

But this isn’t the root of my entry today. Most of us know about proper forum etiquette, and if you the reader don’t, well I’m wondering how you even found my blog. I don’t think you’d be pleasuring yourself here in my blog if you didn’t know this basic stuff.

My real point about this is on forums where they ignore you because you properly asked a question.

Who here has ever gone to a forum and did you best to supply all the relevent information for your question. What occurred, how it occurred, what actions you took to remedy it, a short description of places you’ve searched or search words you used to locate an answer, and everything. Sometimes though this leads to a post about a paragraph or two in length. And oddly your thread gets burried in a heart beat. No matter how often you’ve come to this forum and offered up your time and mind to help anyone coming in with a question, yet no one will even offer a “sorry bro, I’m not sure.”

This is when things get more aggravating for me. I understand that possibly everyone is just as stumped as I am and doesn’t want to look stumped on the world wide web. But some of my questions can’t be all that hard. I don’t know everything, I’m a normal regular guy, so there is probably a lot I don’t know that you do. Actually I’m certain of it because I’ve learned a lot from everyone else on forums… that is why I hang out at them.

I am convinced inside that people just don’t want to read my post. As if 100 words is far to much for them to waster their precious time on. People have gotten into the habit of posting short inconcise questions because it’s the only way they’ll get someone to even read their post. Where has our reading comprehension gone? I can type about 50+ words a minute, not to shabby, but still kind of slow compared to professional typists. Bearing in mind at 50+ wpm I’ll probably have a couple spelling and grammatical errors. On the internet with the influx of “teh”, “roxxor” and other garbage I don’t think “obviousily” is going to be that big of a deal. I think you understand what I spelled!

If I can put together a thought and write it down in text in just 2 minutes, it shouldn’t take you any longer to read it. We’re on a forum, if your reading speed is that slow I’d advise you leave a medium of text far behind!

So my question to everyone is this. What is the right way to ask a question? I know the wrong way, or so I thought I did. But what is the correct format I should approach?

More content… I’m just starting

It’s my first day with this new blog after the complete rehaul of my website. I wanted to get together some content for the start up of what I hope to be a blog I update habitually. I want to get some variety on here for the first week, comedy, tech, music, etc. So I pulled this off the forum I spend most my time at racketboy.com . A thread was created asking for your “transcendent geek moment”. These were a few of my responses that got some good laughs. Maybe you’ll enjoy as well.

them: “Why is there a Linear Algebra book on the back of your toilet?”
me: “I like to read it when I’m, you know.”
them: “What the hell IS Linear Algebra?”

them: “Dude, I called you like 3 times today with no answer, what the hell are you doing?”
me: “Working on a triangulation algorithm.”
them: “uhhh, k.”
me: “I’m working on a Risk AI engine, this will help the computer find its way around the map.”
them: “uhhhh, k.”

them: “Man, you like Sega? Remember the Genesis? I still own one and a Nintendo.”
me: “Really, that’s cool. Wanna go play some games.”
them: “Nah, I don’t feel like going to my house.”
me: “You haven’t looked in that closet have you.”
them: ::opens drapes to closet in living room:: “WHAT THE HELL!? Are these all yours!?”

her: “We don’t spend enough time together.”
me: “Killing Zophar.”
her: “But don’t you miss me.”
me: “End boss, Zophar, leave me be.”
her: “But honey.”
me: “Can’t see, get off my lap.” … attempt to look around her… “ZOPHAR.” push her off my lap.

them: “I thought you hated the PS2 and swore to never buy one.”
me: “I won’t, thing is evil.”
them: “Then what’s this.”
me: “Didn’t buy that.”
them: “Some one give it to you?”
me: “No, built it out of parts left over when I repaired other PS2s.”