# The VHDL standard's own float package returns the wrong answer for sqrt(2)

Original title: The VHDL standard's float package gets sqrt(2) wrong

> Hacker News story 50499188 · language: en · submitted 2026-11-14
> Web version: https://zeli.app/story/50499188
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 15 · by [lmtlssss](<https://news.ycombinator.com/user?id=lmtlssss>) · 💬 6
[original](<https://github.com/lmtlssss/speedrunpapi/tree/main/hardware/audit/ieee-float-pkg>) · [HN discussion](<https://news.ycombinator.com/item?id=50499188>)

## Summary

An audit of ieee.float_pkg, the floating-point package shipped in IEEE 1076-2008 and 1076-2019 and bundled unchanged in GHDL and NVC, compares every operation against exact arithmetic. Plain calls already fail: sqrt(2.0) in float64 lands one unit off, mac(-6.0, -1.0, -5.0) returns -15.0, and some resizes crash the simulator. Across 10,000-call sweeps, mac is wrong roughly a quarter of the time under round_nearest, and sqrt misses 735 of 10,000 float32 cases. The author traces each fault to specific lines and offers a 33-hunk patch.

## Key quote

> Of the integers 1 to 4,096, sqrt returns a float32 one unit off for 256 and a float64 one unit off for 264.

## HN discussion (6 comments)

### [bee_rider](<https://news.ycombinator.com/item?id=50499744>)

> The first link in the post doesn’t seem to be valid (on my iPhone at least). Maybe it is an issue of mobile safari not wanting to open… a vhdl blob, though? Maybe double check that, a link to their main page could be more useful.
>
> [edit, it seemed to work the second time, I dunno, maybe it was just a temporary issue, sorry!]
>
> Also, it looks like in the last six minutes (as of me writing this post) the README was updated with an intro that starts thing off with a better high-level description of what’s going on. I think the write-up could still use some work. But it isn’t entirely useless, really, this sort of library should be fully correct, down to the ULP, it is quite foundational after all.

### [rustybolt](<https://news.ycombinator.com/item?id=50499555>)

> My god this is utterly unreadable for humans.

### [IshKebab](<https://news.ycombinator.com/item?id=50499567>)

> ... by one ULP. Anyway I don't think anyone is just feeding a raw sqrt into their synthesiser.

---

## Cite

- Page: https://zeli.app/story/50499188
- Date: 2026-11-14
- Source: github.com (https://github.com/lmtlssss/speedrunpapi/tree/main/hardware/audit/ieee-float-pkg)
- Hacker News: https://news.ycombinator.com/item?id=50499188

## Other languages

- zh: https://zeli.app/zh/story/50499188 · markdown: https://zeli.app/zh/story/50499188.md
- ja: https://zeli.app/ja/story/50499188 · markdown: https://zeli.app/ja/story/50499188.md
- ko: https://zeli.app/ko/story/50499188 · markdown: https://zeli.app/ko/story/50499188.md
- de: https://zeli.app/de/story/50499188 · markdown: https://zeli.app/de/story/50499188.md
- es: https://zeli.app/es/story/50499188 · markdown: https://zeli.app/es/story/50499188.md
- ru: https://zeli.app/ru/story/50499188 · markdown: https://zeli.app/ru/story/50499188.md
