A Crash Course in Floating Point Numbers (and why XNA is stupid)

March 29, 2009 at 2:50 pm | Posted in Blogroll | 1 Comment

(Note: If the following makes no sense, then I’m not very good at explaining the concept and hence I will most likely fail at least part of my exams this year, anyway…)

Floating point number are how a computer can represent a decimal number in memory.   As most of you should know, a computer works with everything in 1s and 0s, which are bits.  When a floating point number is created, the bits used to create the number are split into two groups, an exponent and a mantissa.  The mantissa creates a little binary decimal.  It’s very fiddley because of the way bits but 0.1 = 1/2, 0.01 = 1/4, 0.11 = 3/4.  If that doesn’t make sense to you, don’t worry, I can’t be asked to go into a huge amount of detail here. The mantissa is then multiplyed by 2 to the power of the exponent, giving you a wide range of numbers to work with.

Let’s focus on the mantissa, the more bits you have to work with, the more precise a number will be.  Think about it, let’s try to represent 0.1 (normal 0.1 as in a tenth) in binary

with 4 bits, the closest you can get is 0.0010 (i.e. an eigth, 0.125)

however, if you use twice that, the closest is 0.00011001 (25/256, 0.09765625)

As you can see, using twice as many bits allows you to be far more accurate.

There are two main types of floating bit numbers used in computers, single and double precision.  Single precision uses 32 bits (split between the mantissa and the exponenet) and double precision uses 64 bits.  As numbers take up such a small amount of space and memory isn’t an issue in this day and age, we have been advised to use double precision numbers at every opportunity
Why am I bringing this up?  Well, XNA Game Creator doesn’t seem to understand some simple concepts and constantly require you to have to add extra chunks of code to make it convert numbers from single to double precision floating point numbers (or vica versa) because it will moan if you use the wrong one.  Not only that, but it asks you to use each one for specific things on different occassions.

For example, a vector requires two values of double precision

For drawing something at a particular angle, you need it to be single precision, however if you want to apply any trigonometry to it, it has to double precision.  Also, any inverse trig rules will output a double precision number so to use it in drawing an object, you need to convert.

In fact pretty much anything involving a calculation involves double precision and every drawing uses single.  Now, I know that’s the sensible way around to have it, but I don’t see what the problem would be is everything was designated to be a double precision number?

Add that to the fact you need to keep some things as integers and…GAH!

Today is a new day, just like yesterday was…

March 4, 2009 at 4:14 pm | Posted in Blogroll | Leave a comment

I’m in a generally pretty good mood right now, I mean I most certainly haven’t fixed any of the “issues” I seem to have constantly in my life, but at I seem to have moved into another phase of it not bothering me quite so much.

There’s just a few small things that have cheered me up a bit too, despite having a ridiculously constant stream of work right now (and as a result not even starting to write my smoker audition). I seem to be doing a lot more random small events, like squash, having friends from other colleges round for formal and going to see some more comedy tonight (Derek). For once, I’ve actually managed to be organised for once and am setting up a halo doubles tournament. The great thing about this is that it’s probably going to be in the auditorium now, so yay! Big screen! Simple things please simple minds…

Also, I came back from town thinking I’d like something sweet to eat, but didn’t think I had anything, then found the fruit sherbets Nick left on my bed from last night :D

Finally, two random things that made me laugh, firstly from the bottom of the stand-up section of the bulletin:
“p.s if you are lacking in friendships its worth noting that funny people tend to have them-maybe this is your chance.”

and this, which I could easily see happening to me

Missing Stuff…

February 23, 2009 at 9:48 am | Posted in Blogroll | Leave a comment

Ok, there’s something seriously wierd going on.

I’ve lost my phone for the second time in two days, but although I haven’t managed to misplace it before, I’m aware of where I must’ve dropped it both times.

The strange thing is, the amount of other stuff that’s gone missing, from WITHIN my room. My hat and my only bowl (I was actually going to have breakfast this morning!) have both gone missing (and I’m sure there’s other things I can’t even remember right now).

Things this size are not exactly easy to lose in a room here, what the fudge is happening?

Back to Blogging

February 21, 2009 at 7:25 pm | Posted in Blogroll | Leave a comment

I just feel like putting a little buffer here to say I’m starting to use this as a blog again, before I do the crazy idea of linking it to my facebook account, so I embarass myself in front of all my college friends at Cambridge…

So, yeah, maybe an update on various things, or my current thoughts coming shortly

Red and White

March 1, 2008 at 10:55 pm | Posted in Blogroll | 1 Comment

Red grapes are completely rubbish, I’ve always thought white grapes are FAR FAR better.  In fact I’m not a huge fan of red wine either, I only drink white if I ever have any wine.  There’s something about red grapes which aren’t quite as sweet and it just doesn’t work.

Of course I was thinking the same for olives, although I had some REALLY nice red olives today, far better than the white ones on offer.  Mind you, they were seedless and it’s normally the seeded red olives I don’t really like…

Back to grapes, why are they called red and white anyway? “Red” grapes are more purpley and “white” grapes are most definately green, what’s up with that? 

P.S. I wasn’t ever going anywhere with this
P.P.S I am not trying to be racist to grapes/olives


March 1, 2008 at 7:25 pm | Posted in Blogroll | 2 Comments

Do you reckon you can buy a calender for the current year in march? Probabbly, o welll, I’ll write some of my stuff down here, because I’m picky with the stuff I buy (yes I have been buying other random things, but that’s besides the point).

So currently planned (well, except the first one really):

  • 9th March, US Brawl release date — grrrr
  • 20th March, JoCo Concert in London — wooo!
  • Sometime after, Probabbly an episode or two of lone wolves
  • Sometime between, paintballing, most likely, tis good fun
  • 15th August, Finish work
  • 20th August, Video Games Live Concert
  • 20th-25th August, Leipzig games convention (biggest consumer show, TGS and GDC are devs only and Leipzig is bigger than E3 now)
  • Early October, Start Uni at Cambridge

Not Forgotten

February 22, 2008 at 12:40 am | Posted in Blogroll | Leave a comment

I haven’t forgotten about this blog, not in the slightest…

See? I’m posting wirte now!


and now It’s Getting Annoying..

January 28, 2008 at 10:50 pm | Posted in Blogroll | Leave a comment

Ok, all my recent posts have been about Grifball, that’s not about to change, although be prepared for a bit of a rant…

I’ve reported Team Marvelous for being so impossible to organise a game with, despite the fact our first game of the league was against us, so although the gets us a free win, there’s no scores for that and while trying to get a wild card place, getting a good score will be important…

Also, our whole team is messed up at the moment, basically until the playoff period, so our chances of making that stage is hindered.  Jamie’s Xbox hard drive has packed in, the dreaded single red light of doom, ok could be worse, but still, he has to play splitscreen on my xbox until he gets a replacement.  I’m going to be at home this weekend, as will Jamie, but there’s a small slot we can play on saturday which involves me being at Jon’s house playing splitscreen while we use our reserve for the game.  Simialr story for the week after when although me and Jamie will be at the flat, Jon will be at his dad’s so it’s Gavin’s turn to grifball again.

Also, programming grifball is just being a bitch, even the simple stuff…

More Grifball

January 24, 2008 at 11:25 pm | Posted in Blogroll | Leave a comment

Ok, getting on this is just plain awesome

http://files.redvsblue.com/grifball/vids/GBWL_WeekTwo.mov (right click and save as, it’s in .mov format).  It’s currently on the front page of grifball, but it ought to end up in the videos section at some point, it’s week 2’s highlights.

Well, wibble failed, it worked out to be boring and rubbish, but I only spent maybe 20 mins on it, so that’s ok.  TSAH 3 people were actually announced 2 ays ago now, which is annoying, but it’s probabbly a good thing I didn’t get involved…

So, other than The Other Side, which I’ve decided I want to finish something else before going back to, it’s just grifball left, so I’s be working on that now…

Staying up Late…

January 23, 2008 at 12:04 am | Posted in Blogroll | 1 Comment

I don’t seem to be getting to bed too early at the moment, normally about 1 o clock, might manage earlier tonight, but we’ll have to see…

Grifball seems to be going well (I havn’t mentioned that here yet, just go to www.grifball.com, I’m the team captain of Team Chupathingy and I got the first Captain of the week award, yay!).  We won our 5th game, which was against one of the teams I was worried about, the other game we played against a team I was worried about, we lost…  We still have the chance at a playoff place, but only if we win the rest of the games, which would be a nice surprise if it happened.  To be honest, I’m really quite surprised how well we’ve done, but I geuss a lot of people have been in the same position as us and have been completely new to the sport.

Working on something called Wibble at the moment, which was working how I thought it wasn’t, I dunno, some crazy coding I’d come up with which made wierd things happen and now I’m trying to do something.  I thought I understood it, but looking back, I have NO idea what I’ve done.  I’m quite happy with how the Master Chief model (sadly didn’t finish it over the weekend, but o well) and the grifball are going, hopefully neither will take TOO long.

Now I’ve removed the link from hyrule.net (which I’ll probabbly need to replace at some point) the visitors here has probabbly dropped significantly.  Hello Jon!

Next Page »

Create a free website or blog at WordPress.com. | The Pool Theme.
Entries and comments feeds.


Get every new post delivered to your Inbox.