# Hard Cast

As weird as it may sound, all of that somewhat esoteric math that I previously talked about was somewhat tricky to actually implement. First I had the issue of looking around for the command that let’s me figure out the square root of something (an important bit of the Pythagorean Principal), and then I ran into the real problem. You see, most computer languages have lots and lots of different ways to say the same fuggin thing. Let’s explore the menagerie, shall we?

The classic one is an Integer. These little brutes only deal with whole solid numbers. These are the ones most people think about when the term “number” is thrown about. In computer land they take up a reasonable about of space since they have a pretty wide range of numbers. These are what I tend to use the most since I can use some math and get really good mileage out of them.

The first oddity is something called a Bool. These particular beasties can only ever be a 1 or a 0, but take up so little space that they are almost free. These will usually have a special property where the 1 and 0 will be magically translated into True and False. It also works both ways, so you can create a Bool that is equal to one of those like this : Bool Number = True;

Next up is a sweet baby called a Float. The “floating” part of these numbers refers to the “Floating Point” decimal place. These are how we get tiny little fractions like 2.0012. In terms of what I was doing, these kinds of numbers are needed for things like a square root calculation to work. They take up way more space than an Integer though, since the computer has to constantly keep track of the damned decimal point and do all the extra math to make sure it always ends up in more or less the right place.

Finally we have the freakish and rare monster known as the Double. Here the name refers to the space itself. It “Double” the amount used by an Integer. This extra space gives them crazy range in terms of what kinds of numbers that you want to think about. Like, if you were going to build a program that counted up stars, then you’re going to want to use a Double. I almost never use this, since there is almost nothing that I’ve ever had to code that needs numbers that huge.

“But why!? Why assault us with this nonsense?” Well, there’s a reason for that. The issue that I was having tonight is that Int 1, Bool 1, Float 1.0 and Double 1 are not the same gods damned number. Basically I did all of my math using a Float, since I really could use those sweet decimal places to make sure that the square roots worked. When the math was figured out I fed the answers into the waiting, gaping maw of the function that makes enemy bullets.

Then the program had an error. It kept saying (and here come the titles) that I didn’t “Cast” the number correctly. The thing is that even though we know what the number is, the computer doesn’t. That “1” is stored in tables of 1’s and 0’s. So the Integer 1 may look like this : 00001, but the double of the same thing has 63 zeroes instead. The computer, regardless of how much memory it has or how fast the processor may be, is actually a stupid beast. So, what kept me busy for my specified coding time today was trying to make the system convert the numbers.

What I finally found was that I could take almost any similar values and explicitly tell them to do something. So this works : Int Number = (int) FloatNumber;

I know, a “Float Number” does in fact sound like a premium mattress. Anyhow, once I discovered that particular bit of something, the program compiled and those flying fortress enemies proceeded to shoot the shite out of me. They tracked me, the math worked, the bullets streamed out like targeted laser win. The whole system still works for crap, but at least the math worked. No fiddling, no rewriting. Once the casting was worked out, the math proved to be correct from the start. So in spite of all of that, it was a good day for development.