Search code examples
c#dllprecision128-bit

Can't compile console app, using QPFloat, a 128-bit floating-point library


I'm new here.

I have a problem I would love to be helped with. I'm pretty new to c# and I'm trying to use QPFloat library (https://sourceforge.net/p/qpfloat/home/Home/), that supports 128-bit floating-point arithmetic.

I downloaded the source code on GitHub (https://github.com/coder0xff/QPFloat), I unzipped it, and I opened "QPFloat.sln".

I built it on x64 and it created "./x64/Release/QPFloat.dll". Everything ok.

I created a new .net framework 4.6.1 console project on visual studio community 2017, I referenced "QPFloat.dll" and I created the following code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Quadruple a;
            Console.Out.WriteLine(System.Quadruple.Pi.ToString());
            Console.ReadKey();
        }
    }
}

I execute it and it throws me:

An unhandled exception of type 'System.BadImageFormatException' occurred in Unknown Module.
Could not load file or assembly 'QPFloat, Version=1.0.6443.35018, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

I don't have any idea what is wrong. Did "QPFloat.dll" compiled with errors or do I have to add something to my project?

Please don't tell me to use "Decimal" class because it doesn't work for my purpose, because it doesn't use all bits and it's too slow.


Solution

  • I built it on x64 and it created "./x64/Release/QPFloat.dll". Everything ok.

    You built your QPFloat library in 64-bit. I would hazard a guess that you are building your sample console app in Any CPU mode. You should try building it in 64 bit mode too, and hopefully that should resolve your problem