Skip to content

Commit 7229958

Browse files
committed
Add missing parentheses
The macro definition had parentheses, which made it work
1 parent 4c39a04 commit 7229958

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

jsrc/conversions.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ value_if(bool cond, T value) -> std::optional<T> {
5454
template <typename From, typename To, typename Transform>
5555
[[nodiscard]] auto
5656
convert(J jt, array w, void *yv, Transform t) -> bool {
57-
auto *v = pointer_to_values<From>(w);
57+
auto *v = pointer_to_values<From>(w);
5858
auto *result = static_cast<To *>(yv);
5959
if constexpr (is_optional<decltype(t(*v))>::value) {
6060
for (int64_t i = 0; i < AN(w); ++i) {
@@ -87,9 +87,8 @@ template <>
8787
[[nodiscard]] auto
8888
convert<D, bool>(J jt, array w, void *yv, D fuzz) -> bool {
8989
auto const infinity = [](auto p) { return p < -2 || 2 < p; };
90-
return convert<D, bool>(jt, w, yv, [&](auto p) {
91-
return value_if(!infinity(p) && (p == 0.0 || fuzzy_equal(p, 1.0, fuzz)), p != 0.0);
92-
});
90+
return convert<D, bool>(
91+
jt, w, yv, [&](auto p) { return value_if(!infinity(p) && (p == 0.0 || fuzzy_equal(p, 1.0, fuzz)), p != 0.0); });
9392
}
9493

9594
template <>
@@ -101,11 +100,11 @@ convert<D, I>(J jt, array w, void *yv, D fuzz) -> bool {
101100
return std::nullopt; // must equal int, possibly out of range
102101
}
103102
// out-of-range values don't convert, handle separately
104-
if (p < static_cast<D> IMIN) {
103+
if (p < static_cast<D>(IMIN)) {
105104
return value_if(p >= IMIN * (1 + fuzz), IMIN);
106105
} // if tolerantly < IMIN, error; else take IMIN
107106
else if (p >= FLIMAX) {
108-
return value_if(p <= -static_cast<D> IMIN * (1 + fuzz), IMAX);
107+
return value_if(p <= -static_cast<D>(IMIN) * (1 + fuzz), IMAX);
109108
} // if tolerantly > IMAX, error; else take IMAX
110109
return q;
111110
});
@@ -308,8 +307,8 @@ convert<D, Q>(J jt, array w, void *yv, I mode) -> bool {
308307
template <>
309308
[[nodiscard]] auto
310309
convert<Q, D>(J jt, array w, void *yv) -> bool {
311-
auto const xb = static_cast<D>(XBASE);
312-
auto const nn = 308 / XBASEN;
310+
auto const xb = static_cast<D>(XBASE);
311+
auto const nn = 308 / XBASEN;
313312

314313
// TODO: figure out nice algorithm for this
315314
auto const add_digits = [&](auto n, auto v) {
@@ -421,7 +420,7 @@ jtccvt(J jt, I tflagged, array w, array *y) -> bool {
421420
// If n and AN have been modified, it doesn't matter for rank-1 arguments whether the shape of the result is listed
422421
// as n or s[0] since only n atoms will be used. For higher ranks, we need the shape from s. So it's just as well
423422
// that we take the shape from s now
424-
*y = d;
423+
*y = d;
425424
if ((t & CMPX) != 0) {
426425
jtfillv(jt, t, n, static_cast<C *>(yv)); // why?? just fill in imaginary parts as we need to
427426
}
@@ -445,7 +444,7 @@ jtccvt(J jt, I tflagged, array w, array *y) -> bool {
445444
}
446445
}
447446
switch (CVCASE(CTTZ(t), CTTZ(wt))) {
448-
case CVCASE(INTX, B01X): return convert<bool, int64_t>(jt, w, yv);
447+
case CVCASE(INTX, B01X): return convert<bool, int64_t>(jt, w, yv);
449448
case CVCASE(XNUMX, B01X): return convert<bool, X>(jt, w, yv);
450449
case CVCASE(RATX, B01X):
451450
GATV(d, XNUM, n, r, s);

0 commit comments

Comments
 (0)