Wednesday, March 10, 2010

Wierd things

Last night at about 1 a.m. I was trying to put some tests to reveal the difference in calculating floats and doubles. The idea was simple - fix a time when the test stars, put in a loop for 1 million times some equations like multiplying and finding a square root of the number, and then fix the end time so do subtract it from the start time.

In first test floats were used. The number like 123456.78 was multiplied, divided, square rooted and etc. for fixed amount of iterations. And then, using doubles (big numbers from previous post) the same type of test was performed.

I was shocked that rather small float numbers had a higher results than doubles!

This is truly the result that let me think more closely to use doubles instead of floats without any doubts regarding performance.

4 comments:

  1. hi,
    I am interested in participating of your project, do you plan on using CVS or SVN to allow other developers to assist you with the code?

    I have some experience with jmonkey, java 3d and physics sims (nothing big, though, just some hobbies projects).
    I have some understanding on AI, including genetic programming and neural networks.

    I was working on a similar project for myself but such a project is too demanding for just one person, too many areas to cover and such...

    well, if you want to talk, my email is cristianorj at gmail dot com

    cya

    ReplyDelete
  2. hi,
    I am interested in participating of your project, do you plan on using CVS or SVN to allow other developers to assist you with the code?

    I have some experience with jmonkey, java 3d and physics sims (nothing big, though, just some hobbies projects).
    I have some understanding on AI, including genetic programming and neural networks.

    I was working on a similar project for myself but such a project is too demanding for just one person, too many areas to cover and such...

    well, if you want to talk, my email is cristianorj@gmail.com

    cya

    ReplyDelete
  3. Hello. I have been working with making a scifi space sort of deal.

    One of the problems I dealt with right from the start was a object manager which would handle such large things as planets and suns and stuff to make sure they stay in the view frustrum. What this manager does is it sends a line out to each object and gets it at a set distance (say 900 units) away and puts the object at 900 units and scales it down to size so it appears as tho it is far away.

    Anyways, I was just starting to get into this concept of large numbers and I ran into your blog. I am trying to conceive a number system to work with AU and such without translating large integers and doubles into AU units, however I dont know if there is any way around it. haha. anyways I will be following your stuff.

    If you want to share code or ideas hit me up on my hotmail email joshaurich@hotmail.com

    ReplyDelete
  4. Cristiano
    At the moment I do not use any team development tools like SVN, and do the project in my free time, which under certain circumstances runs short right now. Atm, I am switching to Java Monkey Engine v3, so not a lot of work is going as to development.

    Joshua
    In my mind I was keeping the same for managing distant objects like you have, but there are always two things to deal with:
    1. Rendering. As to me, I think the only way to visualize such distant objects is to scale them down exponentially to distance.
    2. Computing and dealing with global (real) coordinates. AU can be great, but not necessary since I think to compute in doubles only the celestial object's center, and everything near it will be computed as floats. Anyway these sort of computations with big numbers are needed only to calculate the distance to the object's center (like to know the distance to Mars from Earth).

    ReplyDelete