0

I'm having a hard time getting a straight answer about long double precision on ARM64 architecture. I'm engineering a scientific machine requiring extreme precision, and the driver, which I will write in c++, must keep rounding errors to a minumum. I'll probably use a pi 3B+ for the prototype and some sort of ARM64 architecture for the finished product, but I'm concerned about rounding errors.

I have two questions. First, is the long double supported natively in g++ on the pi with the same precision of x86_64 machines? Second, if it is not, how can I use more digits in my calculations on ARM64 architecture? I'm not averse to linking libraries.

  • 2
    This isn't a Pi specific question. If I wanted an answer I would probably ask on raspberrypi.org/forums simply because I know some who are very knowledgeable about gcc answer questions on there. – joan Oct 13 at 8:52
  • 1
    Have you tried to create a sample program that works OK on X86_64 (so you know the expected answer). Then compile on a Raspberry and compare the results. gcc on both systems should produced code that gets identical results. – Dougie Oct 13 at 10:43
0

The libraries libboost and libboost-math install on the pi with a simple apt-get install on Ubuntu 18.04 (ARM64 version). However, the precision which can be achieved without a license is dependent upon the GMP library, but this is also available via apt-get.

sudo apt-get install libboost1.65-dev
sudo apt-get install libboost-math1.65-dev
sudo apt-get install libgmp-dev

To compile, libgmp needs to be linked to g++ via -lgmp. The following code achieves 50 digit precision, which is good enough for me.

#include <boost/multiprecision/gmp.hpp>
#include <iostream>

using namespace boost;
using namespace multiprecision;

int main()
{
    std::cout.precision(std::numeric_limits<mpf_float_50>::digits10);
    std::cout << mpf_float_50(acos(-1.0)) << std::endl;
    return 0;
}

The output is

3.141592653589793115997963468544185161590576171875

https://www.boost.org/doc/libs/1_71_0/libs/multiprecision/doc/html/boost_multiprecision/tut/floats/gmp_float.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.