oozcitak / exiflibrary

A .Net Standard library for editing Exif metadata
MIT License
131 stars 48 forks source link

MathEx.UFraction32 with big error? #99

Open FSofTlpz opened 2 years ago

FSofTlpz commented 2 years ago

I have found in real coordinates a MathEx.UFraction32 with numerator = 29964 and denominator = 3125. This is 9.58848.

But if create a MathEx.UFraction32 with v = new MathEx.UFraction32(9.58848), v has the nominator = 48 and the denominator 5. This is 9.6. The difference is to hight for me. Is there no way to get a better v?

For this time i use my own simple Function:

      MathEx.UFraction32 getUFraction32ForFloat(float f) {
         uint numerator = (uint)(f * 100000000);
         uint denominator = 100000000;
         while (numerator == (numerator / 10) * 10) {
            numerator /= 10;
            denominator /= 10;
         }
         return new MathEx.UFraction32(numerator, denominator);
      }