default to •internal.EEqual comparing 0 and ¯0 as equal

This commit is contained in:
dzaima 2023-04-02 15:08:59 +03:00
parent 00a5ddcb89
commit c76adb8b35
9 changed files with 12 additions and 13 deletions

View File

@ -275,7 +275,7 @@ po ← { # parsed options
args ( o3) / "-O3"
args ( native) / "-march=native"
args ( debug) / "-DDEBUG"
args ( rtverify) / "-DRT_VERIFY", "-DEEQUAL_NEGZERO"
args ( rtverify) / "-DRT_VERIFY"
args ( heapverify) / "-DHEAP_VERIFY"
args ( exportSymbols) / "-DCBQN_EXPORT"
args ( ¬pie) / "-fno-pie"

View File

@ -113,7 +113,7 @@ Namespace of various internal functions. May change at any time.
| `•internal.Variation` | Convert `𝕩` to the variation specified in `𝕨` |
| `•internal.ClearRefs` | Clear references `•internal.Variation` made for `*Inc` variations |
| `•internal.Unshare` | Get a unique, reference count 1 version of the argument; recursively unshares array items, doesn't touch namespaces |
| `•internal.EEqual` | exactly equal (NaN equals NaN); 0 and ¯0 aren't equal, but can be made so with the C compile-time flag `-DEEQUAL_NEGZERO` |
| `•internal.EEqual` | exactly equal (NaN equals NaN, 0 equals ¯0) |
| `•internal.Temp` | place to test new features or temporarily expose some internal function |
# FFI

View File

@ -16,7 +16,7 @@ debug1:
rtperf:
@"${MAKE}" i_singeli=0 i_t=rtperf i_f="-O3 -DRT_PERF" run_incremental_0
rtverify:
@"${MAKE}" i_singeli=0 i_t=rtverify i_f="-DDEBUG -O3 -DRT_VERIFY -DEEQUAL_NEGZERO" run_incremental_0
@"${MAKE}" i_singeli=0 i_t=rtverify i_f="-DDEBUG -O3 -DRT_VERIFY" run_incremental_0
heapverify:
@"${MAKE}" i_singeli=0 i_t=heapverify i_f="-DDEBUG -g -DHEAP_VERIFY" run_incremental_0
wasi-o3:

View File

@ -513,7 +513,7 @@ bool equalSlow(B w, B x, usz ia) {
bool atomEEqual(B w, B x) { // doesn't consume (not that that matters really currently)
if (w.u==x.u) return true;
#if EEQUAL_NEGZERO
#if !NEEQUAL_NEGZERO
if (isF64(w)&isF64(x)) return w.f==x.f;
#endif
if(isF64(w)|isF64(x)) return false;
@ -550,10 +550,10 @@ bool eequal(B w, B x) { // doesn't consume
f64* xp = f64any_ptr(x);
u64 r = 1;
for (usz i = 0; i < ia; i++) {
#if EEQUAL_NEGZERO
r&= (wp[i]==xp[i]) | (wp[i]!=wp[i] & xp[i]!=xp[i]);
#else
#if NEEQUAL_NEGZERO
r&= ((u64*)wp)[i] == ((u64*)xp)[i];
#else
r&= (wp[i]==xp[i]) | (wp[i]!=wp[i] & xp[i]!=xp[i]);
#endif
}
return r;

View File

@ -13,8 +13,8 @@ test/moreCfgs.sh path/to/mlochbaum/BQN // run "2+2" in a bunch of configurations
./BQN test/bit.bqn // fuzz-test •bit functions
./BQN test/mut.bqn // fuzz-test mut.h (currently just bitarr fill); requires -DTEST_MUT
./BQN test/hash.bqn // fuzz-test hashing
./BQN test/squeezeValid.bqn // fuzz-test squeezing giving a correct result; requires -DEEQUAL_NEGZERO
./BQN test/squeezeExact.bqn // fuzz-test squeezing giving the exact smallest result; requires -DEEQUAL_NEGZERO
./BQN test/squeezeValid.bqn // fuzz-test squeezing giving a correct result
./BQN test/squeezeExact.bqn // fuzz-test squeezing giving the exact smallest result
./BQN test/various.bqn // tests for various small things
./BQN test/random.bqn // test (•MakeRand n).Range
./BQN test/joinReuse.bqn // test in-place join; requires -DPRINT_JOIN_REUSE

View File

@ -1,4 +1,4 @@
# make f='-O3 -march=native -DTEST_BITCPY' singeli=1 c && ./BQN test/bitcpy.bqn
# make o3-singeli f=-DTEST_BITCPY && ./BQN test/bitcpy.bqn
Temp, Type, Unshare, Squeeze, Info, Variation •internal
u 100×(•UnixTime+1|100וMonoTime)@
# u ↩ 123

View File

@ -1,4 +1,3 @@
# make f='-march=native -O3 -DEEQUAL_NEGZERO' singeli=1 c && ./BQN test/squeeze.bqn
EEqual, ListVariations, ClearRefs, Variation, Squeeze, Info •internal
u 100×(•UnixTime+1|100וMonoTime)@
# u ↩ 123

View File

@ -8,7 +8,7 @@ min ← 0∾(-2⋆7‿15‿31)∾¯0.5∾0‿0‿0
max 2( 271531) 0.5(2816)1114112
szs max-min
chr 00000111
specF64 (- π2 1÷0) (0÷0) -0÷0
specF64 (- π2) (0÷0) -0÷0
specI32 "Ai32" •internal.Variation (<(231)(-231))/ - 0/ (¯4+8) + 232
vars "Ab""Ai8""Ai16""Ai32""Af64""Ac8""Ac16""Ac32"
casts 1816326481632¨"uiiifccc"

View File

@ -86,6 +86,6 @@ Mod ← {𝕊:
# •Show "heap corruption test of bit/i32" ⋄ "Ai32"‿1‿50 BitSlash 1000000
{
¬0 EEQ -0? •Out "Skipping tests requiring EEQUAL_NEGZERO";
¬0 EEQ -0? •Out "Skipping tests requiring !NEEQUAL_NEGZERO";
•Show "⊔ consistency" Group 10000
}