fix F`fillarr leaking fill element

also print higher precision numbers
This commit is contained in:
dzaima 2021-06-01 17:13:43 +03:00
parent 62209961eb
commit b8c362247b
4 changed files with 5 additions and 4 deletions

View File

@ -87,10 +87,10 @@ B each_c2(B d, B w, B x) { B f = c(Md1D,d)->f;
B scan_c1(B d, B x) { B f = c(Md1D,d)->f;
if (isAtm(x) || rnk(x)==0) thrM("`: Argument cannot have rank 0");
B xf = getFillQ(x);
ur xr = rnk(x);
usz ia = a(x)->ia;
if (ia==0) return x;
B xf = getFillQ(x);
if (xr==1 && TI(x).elType==el_i32 && isFun(f) && v(f)->flags) {
u8 rtid = v(f)->flags-1;
i32* xp = i32any_ptr(x);

View File

@ -41,7 +41,7 @@ B repr_c1(B t, B x) {
#define BL 100
if (isF64(x)) {
char buf[BL];
snprintf(buf, BL, "%g", x.f);
snprintf(buf, BL, "%.14g", x.f);
return m_str8(strlen(buf), buf);
} else {
#ifdef FORMATTER

View File

@ -85,6 +85,7 @@ NOINLINE void harr_pfree(B x, usz am) { // am - item after last written
assert(v(x)->type==t_harr);
B* p = harr_ptr(x);
for (usz i = 0; i < am; i++) dec(p[i]);
if (rnk(x)>1) ptr_dec(shObj(x));
mm_free(v(x));
}

View File

@ -99,7 +99,7 @@ NOINLINE void print(B x) {
NOINLINE void printRaw(B x) {
if (isAtm(x)) {
if (isF64(x)) printf("%g", x.f);
if (isF64(x)) printf("%.14g", x.f);
else if (isC32(x)) printUTF8((u32)x.u);
else thrM("bad printRaw argument: atom arguments should be either numerical or characters");
} else {
@ -196,7 +196,7 @@ NOINLINE B append_fmt(B s, char* p, ...) {
AU("¯");
f=-f;
}
snprintf(buf, 30, "%g", f);
snprintf(buf, 30, "%.14g", f);
A8(buf);
break;
}