mirror of
https://github.com/ivabus/pantry
synced 2024-11-10 02:25:18 +03:00
+mpdecimal (#70)
This commit is contained in:
parent
0f35c7d2be
commit
70d0af6b81
21
projects/bytereef.org/mpdecimal/package.yml
Normal file
21
projects/bytereef.org/mpdecimal/package.yml
Normal file
|
@ -0,0 +1,21 @@
|
|||
distributable:
|
||||
url: https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-{{ version }}.tar.gz
|
||||
strip-components: 1
|
||||
|
||||
versions:
|
||||
- 2.5.1
|
||||
|
||||
build:
|
||||
dependencies:
|
||||
tea.xyz/gx/cc: c99
|
||||
tea.xyz/gx/make: '*'
|
||||
script: |
|
||||
./configure --prefix={{ prefix }}
|
||||
make --jobs {{ hw.concurrency }} install
|
||||
|
||||
test:
|
||||
dependencies:
|
||||
tea.xyz/gx/cc: c99
|
||||
script: |
|
||||
cc {{ pkg.pantry-prefix }}/test.c -o test -lmpdec
|
||||
./test
|
22
projects/bytereef.org/mpdecimal/test.c
Normal file
22
projects/bytereef.org/mpdecimal/test.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
#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;
|
||||
}
|
Loading…
Reference in a new issue