small (short) float?

Started by
11 comments, last by neonfaktory 20 years, 9 months ago
Yeah, floats would be faster than fixed point in most cases, unless you're doing a lot of float -> integer conversions, which it doesn't appear you'd be doing.

Although, most of the work you'd be doing would be subtraction and addition I'd presume, and integer addition/subtraction is plenty fast. Who knows, just use:

typedef MyFloat float;

Then write the program and get it to work, benchmark.. then change the typedef to...

typedef MyFloat Fixed16_S;

Program should still work the same, benchmark and see which was faster. It's not that hard to test out because both float types are treated the same in code, so no changes should have to be made to test them!

--- Edit ---
By the way, in your structs/classes, I mean to use MyFloat as the data type instead of float or Fixed16_S, so it's as simple as changing your typedef to change all the types instead of doing it manually. Once you find the most efficient method, stick to it .

[edited by - Ready4Dis on July 6, 2003 9:17:13 AM]
Advertisement
if you take a look at the precision loss, it follows a distinct pattern (i just noticed) im working on a way to improve acuracy, i will post the results soon..


A GOOD friend will come bail you out of jail...
but, a TRUE friend will be sitting next to you saying, "Damn, we fucked up."

Ingite 3D Game Engine Home -- Just click it
"I am a donut! Ask not how many tris/batch, but rather how many batches/frame!" -- Matthias Wloka & Richard Huddy, (GDC, DirectX 9 Performance)

http://www.silvermace.com/ -- My personal website
ok, ive done a quick rough up, i think i will fiddle a bit more and
see what i can come up with

so far
on a quick test of 3000 floats the average error is: 0.00209244
reasonable considering it takes up exactly half the memory
space!

ive implemented 2 methods of error compensation
  • odd/even compensation, works nicely and i think with
    developement is the one to watch as the precision loss follows a
    pattern.
  • average error compensation, this method simply adds the average
    error levels, its fast and works very well (better than o/e
    currently) the demo uses this method

    with minimal modification the template class float16 should be able to even compress down to 8bits with a developed error algorithm.

    the download is availible from my site
    (in about 10 mins after this post plz)

    CODE
    Please, if you download the code, take a second to e-mail me or post here, id really like to see how many downloads this gets

    silvermace007@hotmail.com

    compiled on g++ 3.xx
    g++ -W -Wall _float.cpp -O6 -o flt

    have fun.




    A GOOD friend will come bail you out of jail...
    but, a TRUE friend will be sitting next to you saying, "Damn, we fucked up."
    Ingite 3D Game Engine Home -- Just click it


    [edited by - silvermace on July 7, 2003 6:43:47 AM]
  • "I am a donut! Ask not how many tris/batch, but rather how many batches/frame!" -- Matthias Wloka & Richard Huddy, (GDC, DirectX 9 Performance)

    http://www.silvermace.com/ -- My personal website

    This topic is closed to new replies.

    Advertisement