frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Show HN: Stacky – certain block game clone

https://www.susmel.com/stacky/
2•Keyframe•1m ago•0 comments

AIII: A public benchmark for AI narrative and political independence

https://github.com/GRMPZQUIDOS/AIII
1•GRMPZ23•1m ago•0 comments

SectorC: A C Compiler in 512 bytes

https://xorvoid.com/sectorc.html
1•valyala•3m ago•0 comments

The API Is a Dead End; Machines Need a Labor Economy

1•bot_uid_life•4m ago•0 comments

Digital Iris [video]

https://www.youtube.com/watch?v=Kg_2MAgS_pE
1•Jyaif•5m ago•0 comments

New wave of GLP-1 drugs is coming–and they're stronger than Wegovy and Zepbound

https://www.scientificamerican.com/article/new-glp-1-weight-loss-drugs-are-coming-and-theyre-stro...
3•randycupertino•6m ago•0 comments

Convert tempo (BPM) to millisecond durations for musical note subdivisions

https://brylie.music/apps/bpm-calculator/
1•brylie•9m ago•0 comments

Show HN: Tasty A.F.

https://tastyaf.recipes/about
1•adammfrank•9m ago•0 comments

The Contagious Taste of Cancer

https://www.historytoday.com/archive/history-matters/contagious-taste-cancer
1•Thevet•11m ago•0 comments

U.S. Jobs Disappear at Fastest January Pace Since Great Recession

https://www.forbes.com/sites/mikestunson/2026/02/05/us-jobs-disappear-at-fastest-january-pace-sin...
1•alephnerd•11m ago•0 comments

Bithumb mistakenly hands out $195M in Bitcoin to users in 'Random Box' giveaway

https://koreajoongangdaily.joins.com/news/2026-02-07/business/finance/Crypto-exchange-Bithumb-mis...
1•giuliomagnifico•11m ago•0 comments

Beyond Agentic Coding

https://haskellforall.com/2026/02/beyond-agentic-coding
3•todsacerdoti•12m ago•0 comments

OpenClaw ClawHub Broken Windows Theory – If basic sorting isn't working what is?

https://www.loom.com/embed/e26a750c0c754312b032e2290630853d
1•kaicianflone•14m ago•0 comments

OpenBSD Copyright Policy

https://www.openbsd.org/policy.html
1•Panino•15m ago•0 comments

OpenClaw Creator: Why 80% of Apps Will Disappear

https://www.youtube.com/watch?v=4uzGDAoNOZc
2•schwentkerr•19m ago•0 comments

What Happens When Technical Debt Vanishes?

https://ieeexplore.ieee.org/document/11316905
2•blenderob•20m ago•0 comments

AI Is Finally Eating Software's Total Market: Here's What's Next

https://vinvashishta.substack.com/p/ai-is-finally-eating-softwares-total
3•gmays•21m ago•0 comments

Computer Science from the Bottom Up

https://www.bottomupcs.com/
2•gurjeet•21m ago•0 comments

Show HN: A toy compiler I built in high school (runs in browser)

https://vire-lang.web.app
1•xeouz•23m ago•1 comments

You don't need Mac mini to run OpenClaw

https://runclaw.sh
1•rutagandasalim•24m ago•0 comments

Learning to Reason in 13 Parameters

https://arxiv.org/abs/2602.04118
2•nicholascarolan•26m ago•0 comments

Convergent Discovery of Critical Phenomena Mathematics Across Disciplines

https://arxiv.org/abs/2601.22389
1•energyscholar•26m ago•1 comments

Ask HN: Will GPU and RAM prices ever go down?

1•alentred•26m ago•2 comments

From hunger to luxury: The story behind the most expensive rice (2025)

https://www.cnn.com/travel/japan-expensive-rice-kinmemai-premium-intl-hnk-dst
2•mooreds•27m ago•0 comments

Substack makes money from hosting Nazi newsletters

https://www.theguardian.com/media/2026/feb/07/revealed-how-substack-makes-money-from-hosting-nazi...
6•mindracer•28m ago•0 comments

A New Crypto Winter Is Here and Even the Biggest Bulls Aren't Certain Why

https://www.wsj.com/finance/currencies/a-new-crypto-winter-is-here-and-even-the-biggest-bulls-are...
1•thm•28m ago•0 comments

Moltbook was peak AI theater

https://www.technologyreview.com/2026/02/06/1132448/moltbook-was-peak-ai-theater/
2•Brajeshwar•29m ago•0 comments

Why Claude Cowork is a math problem Indian IT can't solve

https://restofworld.org/2026/indian-it-ai-stock-crash-claude-cowork/
3•Brajeshwar•29m ago•0 comments

Show HN: Built an space travel calculator with vanilla JavaScript v2

https://www.cosmicodometer.space/
2•captainnemo729•29m ago•0 comments

Why a 175-Year-Old Glassmaker Is Suddenly an AI Superstar

https://www.wsj.com/tech/corning-fiber-optics-ai-e045ba3b
1•Brajeshwar•29m ago•0 comments
Open in hackernews

Stuffed-Na(a)N: stuff your NaNs

https://github.com/si14/stuffed-naan-js
156•dgroshev•9mo ago

Comments

axblount•9mo ago
This is usually called NaN-boxing and is often used to implement dynamic languages.

https://piotrduperas.com/posts/nan-boxing

addoo•9mo ago
I appreciate this article a lot more because it contains an iota of benchmarking with an explanation about why this might be more performant. Especially since my first thought was 'wouldn't this require more instructions to be executed?'

The original post seems really weird to me. I would have dismissed it as someone's hobby project, but... that doesn't seem like what it's trying to be.

wging•9mo ago
It's a joke project.
Tuna-Fish•9mo ago
"More instructions to execute" is not synonymous with "slower".

NaNboxing lets you use less memory on certain use cases. Because memory access is slow and caches are fixed size, this is usually a performance win, even if you have to do a few extra ops on every access.

thehappypm•9mo ago
I mean, a modern computer is operating the gigahertz range. Adding a few extra bitwise instructions might be something like a nanosecond. Which is absolutely fleeting compared to memory operations.
jasonthorsness•9mo ago
I wonder if IEEE-754 designers anticipated this use case during development. Great article - this kind of "outside-the-normal-use-case" requires a very careful reading of the specifications/guarantees of the language.
purplesyringa•9mo ago
IEEE-754 seems to say that NaN payloads are designed to contain "retrospective diagnostic information inherited from invalid or unavailable data and results". While NaN boxing in particular probably wasn't the intention, untouched payloads in general absolutely were.
userbinator•9mo ago
It's especially useful since everything is 64 bits uniformly.
pwdisswordfishz•9mo ago
Like JavaScript. Which should immediately raise the question how it could possibly work on engines that employ it themselves. Turns out... it won't.
tetris11•9mo ago
Are there any security implications of NaN-Boxing?

If I encode data into the exponent of these NaN values, propagate them around the internet, and decode them elsewhere.... is that a security risk? Or this just falls into the category of "weird encryption"

rcxdude•9mo ago
Define security risk. Obviously this data could come from untrusted sources. Another consideration is that this data may not serialize correctly: most text serialization protocols will not distinguish different NaN values. It's possible for there to be some data confusion in your pipeline as well, if you don't control all the code that touches those bytes.
ufo•9mo ago
I'd be surprised. It's surprisingly difficult to setialize NaN values. Can't do it on JSON, for example.
yencabulator•9mo ago
Lots of formats just put the IEEE-754 bytes on the wire, as-is. For example, Protocol Buffers: https://protobuf.dev/programming-guides/encoding/
dunham•9mo ago
I learned about this when trying to decode data from Firefox IndexedDB. (I was extracting Tana data.) Their structured clone data format uses nan-boxing for serialization.
AaronAPU•9mo ago
Reminds me of using the highest bit(s) of 64-bit ints to stuff auxiliary data into lockfree algorithms. So long as you’re aware of your OS environment you can enable some efficiencies you couldn’t otherwise.
eru•9mo ago
That's why OCaml has 63 bit integers by default: the language itself uses the last bit to help with GC.
amelius•9mo ago
I'm curious why we have not-a-number, but not not-a-string, not-a-boolean, not-an-enum, and not-a-mycustomtype.
ok_computer•9mo ago
Because representing infinity is not possible outside of symbolic logic and isn’t encodable in floats. I think it is a simple numerical reason and not a deeper computer reason.
Sharlin•9mo ago
Well, infinity is totally representable with IEEE 754 floats. For example 1.0/0.0 == +inf, -1.0/0.0 == -inf, but 0.0/0.0 == NaN.
amelius•9mo ago
A smart compiler should be able to figure out a better value for 0/0, depending on context.

For example:

    for i in range(0, 10):
        print(i/0.0)
In this case it should probably print +inf when i == 0.

But:

    for i in range(-10, 10):
        print(i/0.0)
Now it is not clear, but at least we know it's an infinity so perhaps we need a special value +-inf.

And:

    for i in range(-10, 10):
        print(i/i)
In this case, the value for 0/0 can be 1.
Sharlin•9mo ago
Well, it could, but that would be against the spec. The hardware implements IEEE 754, most languages guarantee IEEE 754, and transforming code so that 0.0/0.0 doesn't result in NaN would be invalid.
ok_computer•9mo ago
I'm incorrect. there's a spec discussed here

https://www.gnu.org/software/libc/manual/html_node/Infinity-...

IncreasePosts•9mo ago
Some common numeric operations can result in non-numbers(eg division by zero - Nan or infinity).

Are there any common string operations with similar behavior?

masfuerte•9mo ago
Out of range substring? Some languages throw an error, others return an empty string. You could return a propagating NaS instead. I don't know what you'd use it for.
cluckindan•9mo ago
Charset translation.

Unicode’s � is basically a symbol for not-a-char.

Sharlin•9mo ago
Because IEEE 754 creators wanted to signal non-trapping error conditions for mathematically undefined operations, and they had a plenty of bit patterns to spare. Apparently back in the 70s and 80s in many cases it was preferable for a computation to go through and produce NaNs rather than trapping instantly when executing an undefined operation. I'm not quite sure what the reasoning was exactly.
wbl•9mo ago
In early FP machines the floating point processor could not take a trap at a faulting instruction precisely: it could only go bad things. Furthermore for programmers and hardware it can be very expensive. Rather than go through a loop and filter NaN out of results it becomes trap every time and resume and is a pain.
IshKebab•9mo ago
It avoids traps which are really inconvenient.
dzaima•9mo ago
Because NaNs come from a standardized hardware-supported type, whereas the rest of those are largely language-specific (and you could consider null/nil as a "not-a-*" type for those in applicable languages; and there are languages which disallow NaN floats too, which completes all combinations).

Itanium had a bit for "not a thing" for integers (and perhaps some older hardware from around the time floats started being a thing had similar things), so the idea of hardware support for not-a-* isn't exclusive to floats, but evidently this hasn't caught on; generally it's messy because it needs a bit pattern to yoink, but many types already use all possible ones (whereas floats already needed to chop out some for infinities).

Sharlin•9mo ago
You can encode not-a-bool, not-a-(utf-8)-string and not-an-enum using one of the invalid bit patterns – that's exactly what the Rust compiler can do with its "niche optimization": https://www.0xatticus.com/posts/understanding_rust_niche/
usefulcat•9mo ago
C++ has std::optional for exactly that purpose.
mathgradthrow•9mo ago
Nana basically means that floating point arithmetic is predicting that your mathematical expression is an "indeterminate form", as in the thing you learn in calculus.
sgerenser•9mo ago
Not-a-boolean would be something like the much maligned tri-state bool pattern: https://thedailywtf.com/articles/What_Is_Truth_0x3f_
stevage•9mo ago
You missed not-a-NaN.
indigoabstract•9mo ago
Also GNU, since it's not-a-unix.
dzaima•9mo ago
This doesn't work on Firefox, as it normalizes NaNs as they're extracted from ArrayBuffers. Presumably because SpiderMonkey uses NaN-boxing itself, and thus just doesn't have any way to represent actual non-canonical NaN floats.
moffkalast•9mo ago
Dammit Mozilla, first no WebGPU, now this?! /s
sjrd•9mo ago
The spec mandates normalization of NaNs in ArrayBuffers. If other engines do not normalize, I believe it's a bug in those engines!
dzaima•9mo ago
Chromium & Node (i.e. V8) do seem to just not normalize:

    arr = new Float64Array([0]);
    arr[0] = new Float64Array(new BigUint64Array([-123n]).buffer)[0];
    [...new Uint8Array(arr.buffer)] // [133, 255, 255, 255, 255, 255, 255, 255]
vhcr•9mo ago
Running the following snippets:

    f = new Float64Array(1)
    dv = new DataView(f.buffer)
    dv.setBigInt64(0, -123n)
    console.log([...new Uint8Array(f.buffer)])

    f = new Float64Array(1)
    new BigUint64Array(f.buffer)[0] = -123n
    console.log([...new Uint8Array(f.buffer)])

    f = new Float64Array(1)
    f[0] = new Float64Array(new BigUint64Array([-123n]).buffer)[0]
    console.log([...new Uint8Array(f.buffer)])

    f = new Float64Array([NaN])
    console.log([...new Uint8Array(f.buffer)])
I get on Chrome:

    [255, 255, 255, 255, 255, 255, 255, 133]
    [133, 255, 255, 255, 255, 255, 255, 255]
    [133, 255, 255, 255, 255, 255, 255, 255]
    [0, 0, 0, 0, 0, 0, 248, 127]
And on Firefox:

    [ 255, 255, 255, 255, 255, 255, 255, 133 ]
    [ 133, 255, 255, 255, 255, 255, 255, 255 ]
    [ 0, 0, 0, 0, 0, 0, 248, 127 ]
    [ 0, 0, 0, 0, 0, 0, 248, 127 ]
It looks like both implementations are buggy, Since both the DataView and buffer versions should be normalized.

https://bugzilla.mozilla.org/show_bug.cgi?id=1393085

haxiomic•9mo ago
That's curious! Does anyone know why the spec was designed to allow so many possible NaN bit patterns? Seems like just one would do!
dzaima•9mo ago
As long as you want all bit patterns to be Some float, there's not really one bit pattern you can chop out of somewhere (or, three, rather - both infinities, and NaN).

Taking, say, the 3 smallest subnormal numbers, or the three largest numbers, or whatever, would be extremely bad for allowing optimizations/algorithms/correctness checkers to reason about operations in the abstract.

brewmarche•9mo ago
You can put diagnostic information about the cause of the NaN in the bits. IEEE754 doesn’t mandate any format though, leaving it up to the implementation. You can check section 6 of IEEE754:2019 (which also talks about the possibility to use it to extend the standard to wider ranges, more infinities or other stuff)
vitaut•9mo ago
I made a garlic nan: https://www.godbolt.org/z/enjv1c7Tf
dgroshev•9mo ago
I love it, how did I not think about this!
scorchingjello•9mo ago
Since the first time I had Indian food sometime in 1987 I have always called naan “not a number bread” and no one has ever laughed. I feel like i may have found my people.
dspillett•9mo ago
This may appeal: https://doubleyoudoubledoubleewe.www.dash.deeohhtee.dash-das...
carterschonwald•9mo ago
The nan bits were intended to help provide more informative float error diagnostics at the language implementation level for non crashing code. I wonder if I’ll ever get to exploring it myself.
johnklos•9mo ago
It's a shame this won't work on VAX.
o11c•9mo ago
Note that there are a lot of exciting new float-related functions in C23, many related to NaN handling, signed zeros, or precision in edge cases. Some have been in glibc for years; others not yet.

The API for `getpayload`/`setpayload`/`setpayloadsig` looks a little funny but it's easy enough to wrap (just consider the edge cases; in particular remember that whether 0 is valid for quiet or signaling NaNs is platform-dependent).

Finally we have a reliable `roundeven`, and the convenience of directly calling `nextup`/`nextdown` (but note that you'll still only visit one of the zeros).

The new `fmaximum` family is confusing, but I think I have it clear:

  without 'imum' (legacy): prefer non-NaN
  with 'imum': zeros distinguished (-0 < +0)
  with '_num': prefer a non-NaN, also signal if applicable
  with '_mag': compare as if fabs first
`totalorder` has been often-desired; the other new comparisons not so much.

`rootn` and `compoundn` are surprisingly tricky to implement yourself. I still have one testcase I'm not sure why I have to hand-patch, and I'm not sure which implementation choice keeps the best precision (to say nothing of correct rounding mode).

Etheryte•9mo ago
> but note that you'll still only visit one of the zeros

Out of curiosity, isn't this what you'd pretty much universally want? Or maybe I misunderstand the intent here?

o11c•9mo ago
I find `nextup/`nextdown` useful for when you want to calculate `{f(nextdown(x)), f(x), f(nextup(x))}` and see if some property holds (or to what degree it holds) for both `x` and its surrounding values. It's annoying that one such surrounding value gets skipped.

That said, quite often you need to handle signed zero specially already, and if you don't the property you're testing might sufficiently differ in the interesting way for the smallest-magnitude subnormals.

clhodapp•9mo ago
I guess I just don't get it because the before & after cases don't seem to be showing remotely comparable use cases.

In the "before" use-cases, the programmer has accidentally written a bug and gets back a single NaN from a logical operation they performed as a result.

In the "after" cases, the programmer already has some data and explicitly decides to convert it to a NaN encoding. But instead of actually getting back a NaN that is secretly carrying their data, they actually get a whole array of NaN's, which duck type differently, and thus are likely to disappear into another NaN or an undefined if they are propagated through an API.

Like.. I get that the whole thing is supposed to be humorously absurd but... It just doesn't land unless there's something technical I'm missing to connect up the pieces.

brap•9mo ago
It sounds like you might be interested in the Enterprise Edition
roywiggins•9mo ago
Four NaNs? Four? That's insane.

https://m.youtube.com/watch?v=feJlRDLX0iQ

yapyap•9mo ago
‘Stuff your nan’ is this intentional? From a UK perspective this sounds wild
phpnode•9mo ago
Stuffed Na(a)N as in naan bread https://commons.m.wikimedia.org/wiki/File:Stuffed_Naan.JPG
gitroom•9mo ago
well i totally relate to calling naan not-a-number bread, it's been stuck in my head ever since i learned about NaNs tbh