Giter VIP home page Giter VIP logo

Comments (4)

asik avatar asik commented on July 24, 2024

There's a Fix32 type in the Experimental folder if you want to play with it. The big performance advantage would be multiplication because you could write it as simply the multiplication of two 64-bit integers and not have to deal with all the splitting and checking for overflow BS that Fix64 has to do (because there are no hardware 128-bit integers). Also in x86 of course it would be faster because the type fits in registers. Apart from that though I wouldn't expect much difference. Most of the perf. loss vs floating-point math is the poor codegen (lack of inlining, enregistering of function parameters etc.) as far as I can tell.

Good ideas about readonly struct and Min/Max functions. Note that Fix64 is fairly immune to those defensive copy issues because almost all the operations are static methods, but it could help for .ToString() and .RawValue.

from fixedmath.net.

vpenades avatar vpenades commented on July 24, 2024

Oh, there's a Fix32 already, I'll take a look at it!

You can specify an attribute so the compiler knows you want inlining:

[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AgressiveInlining)]
public static void SomeMethod()
{
...
}

from fixedmath.net.

asik avatar asik commented on July 24, 2024

Yeah, and I just noticed it's mistakenly called Fix16 but it's really a 32-bit Q15.16 type. Use at your own risk, it's really a draft I didn't spend much time on.
I played around with AgressiveInlining before but I know some people compile this for .NET 4 (Unity3D). Would be worth revisiting indeed.

from fixedmath.net.

Krakean avatar Krakean commented on July 24, 2024

@asik

I played around with AgressiveInlining before but I know some people compile this for .NET 4 (Unity3D).

There is already .NET 4.6 support in up-to-date Unity3D which support AggressiveInlining, so forgot worry about legacy for optimizations sake :)
And, anyway, thanks for your work on FixedMath, please keep going!

from fixedmath.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.