Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

Fix 16-bit encoding for -0.0 on JavaScript

author
Gears
committer
Louis Pilfold
date (Jul 25, 2026, 10:32 AM +0100) commit 01228b1e parent b59d5d8b change-id rlszquxp
+27 -1
+3
CHANGELOG.md
··· 17 17 bit array pattern to extract a `Float` and had a constructor called `Number`. 18 18 ([Surya Rose](https://github.com/GearsDatapacks)) 19 19 20 + - Fixed a bug where `-0.0` would be encoded incorrectly in 16-bit bit array 21 + segments on the JavaScript target. 22 + ([Surya Rose](https://github.com/GearsDatapacks)) 20 23 21 24 ## v1.18.0-rc1 - 2026-07-21 22 25
+18 -1
compiler-core/templates/prelude.mjs
··· 1255 1255 } else if (value === -Infinity) { 1256 1256 buffer[1] = 0xfc; 1257 1257 } else if (value === 0) { 1258 - // Both values are already zero 1258 + // 0 === -0, so we need to do an additional check here 1259 + if (isNegativeZero(value)) { 1260 + buffer[1] = 128; 1261 + } 1262 + // Otherwise, both values are already zero 1259 1263 } else { 1260 1264 const sign = value < 0 ? 1 : 0; 1261 1265 value = Math.abs(value); ··· 1287 1291 } 1288 1292 1289 1293 return buffer; 1294 + } 1295 + 1296 + /** 1297 + * Returns whether or not a value is `-0`, since this cannot be checked using 1298 + * equality. 1299 + * 1300 + * @param {number} value 1301 + * @returns {boolean} 1302 + */ 1303 + function isNegativeZero(value) { 1304 + // One of the few differences between 0 and -0 is that division by -0 returns 1305 + // -Infinity rather than Infinity. 1306 + return 1 / value === -Infinity; 1290 1307 } 1291 1308 1292 1309 /**
+6
test/language/test/language/bit_array_test.gleam
··· 192 192 let assert Ok(sliced) = bit_array.slice(data, 1, 2) 193 193 assert sliced == <<0xBB, 0xCC>> 194 194 } 195 + 196 + // https://github.com/gleam-lang/gleam/issues/6036 197 + pub fn negative_zero_16_bits_test() { 198 + let data = <<-0.0:16>> 199 + assert data == <<0x8000:16>> 200 + }