Skip to content

Conversation

eagleoflqj
Copy link
Member

No description provided.

@eagleoflqj eagleoflqj requested a review from wengxt October 5, 2025 19:11
@wengxt
Copy link
Member

wengxt commented Oct 5, 2025

what's the root cause?

@wengxt wengxt merged commit 1bae691 into master Oct 6, 2025
5 checks passed
@wengxt wengxt deleted the nan branch October 6, 2025 01:21
@eagleoflqj
Copy link
Member Author

Firefox and Safari's JS engine (as well as wasm) implements NaN canonicalization, which is allowing only one specific bit representation of NaN. The following code shows the difference on Chrome and Firefox's console:

const f64 = new Float64Array(1);
const u64 = new BigUint64Array(f64.buffer);

u64[0] = 0x7ff8000000000001n; // NaN #1
const nan1 = f64[0];

u64[0] = 0x7ff8000000000002n; // NaN #2
const nan2 = f64[0];

f64[0] = nan1;
console.log("NaN #1 bits:", u64[0].toString(16));

f64[0] = nan2;
console.log("NaN #2 bits:", u64[0].toString(16));

libime's isValid requires different bit representations of NaN

static int32_t NO_VALUE() {
return isGoodNanf() ? decodeValue(std::nanf("1")) : 0x7fc00001;
}
static int32_t NO_PATH() {
return isGoodNanf() ? decodeValue(std::nanf("2")) : 0x7fc00002;
}

thus works only on Chrome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants