mpdecimal 2.5.0 (new formula)
Closes #69918. Signed-off-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>master
parent
bcc5bcfbec
commit
553c29b70d
|
@ -0,0 +1 @@
|
|||
../Formula/mpdecimal.rb
|
|
@ -0,0 +1,49 @@
|
|||
class Mpdecimal < Formula
|
||||
desc "Library for decimal floating point arithmetic"
|
||||
homepage "https://www.bytereef.org/mpdecimal/"
|
||||
url "https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-2.5.0.tar.gz"
|
||||
sha256 "15417edc8e12a57d1d9d75fa7e3f22b158a3b98f44db9d694cfd2acde8dfa0ca"
|
||||
license "BSD-2-Clause"
|
||||
|
||||
def install
|
||||
system "./configure", "--prefix=#{prefix}"
|
||||
system "make"
|
||||
system "make", "install"
|
||||
end
|
||||
|
||||
test do
|
||||
(testpath/"test.c").write <<~EOS
|
||||
#include <assert.h>
|
||||
#include <mpdecimal.h>
|
||||
#include <string.h>
|
||||
|
||||
int main() {
|
||||
mpd_context_t ctx;
|
||||
mpd_t *a, *b, *result;
|
||||
char *rstring;
|
||||
|
||||
mpd_defaultcontext(&ctx);
|
||||
|
||||
a = mpd_new(&ctx);
|
||||
b = mpd_new(&ctx);
|
||||
result = mpd_new(&ctx);
|
||||
|
||||
mpd_set_string(a, "0.1", &ctx);
|
||||
mpd_set_string(b, "0.2", &ctx);
|
||||
mpd_add(result, a, b, &ctx);
|
||||
rstring = mpd_to_sci(result, 1);
|
||||
|
||||
assert(strcmp(rstring, "0.3") == 0);
|
||||
|
||||
mpd_del(a);
|
||||
mpd_del(b);
|
||||
mpd_del(result);
|
||||
mpd_free(rstring);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EOS
|
||||
system ENV.cc, "test.c", "-o", "test", "-L#{lib}", "-lmpdec"
|
||||
system "./test"
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue