Re: Thoughts about IEEE floating point (-ish) on vax
Anders Magnusson <[email protected]> Sat, 13 Jun 2026 18:13:08 +0200
| Newsgroups | gmane.os.netbsd.ports.vax |
|---|---|
| Message-ID | <[email protected]> |
Hi Mouse! Den 2026-06-13 kl. 16:15, skrev Mouse: >> At first; here is a brief overview what differs between vax and ieee >> floating point: > >> * +NaN/-NaN: vax do have "illegal number" which traps. >> Not really NaN. > > Are IEEE NaNs signed? Yes, as well as zeroes. > >> * Vax exponent bias is (for F-float) 128, IEEE (for single) 127. >> * Vax hidden bit is 0.5, IEEE is 1. > > I'm not entirely sure what you mean here. By the value of the hidden > bit, you mean that (say) if the exponent bits are eee and the mantissa > bits are mmmm, the value is .1mmmm * 2^eee versus 1.mmmm * 2^eee? Now I'm not getting what you mean :-) I try to rephrase: vax: With an (unbiased) exponent of zero and only the hidden bit set the decimal value is 0.5. ieee: With an (unbiased) exponent of zero and only the hidden bit set the decimal value is 1.0. Then the bias is different as well. Note that I have tested a bunch of this myself, on pdp-11, but that should not matter :-) > > To match up the VAX with the IEEE, it needs byteswapping something like > PDP-endian (swap words-within-long but not bytes-within-words) and then > an exponent bias difference of 1. > > IEEE may allow for layout variations, but I suspect some test suites > don't. Yes, that would mean the test suites are broken, but then, > except for things that really do require IEEE for some reason, they're > broken anyway for demanding IEEE. I don't know about test suites, I just read the standard :-) > >> We note that the difference in bias and mantissa is a factor of 4.0. > > Looks like a factor of 2 to me. After bit rearrangement, 1 is biased > exponent 7f for IEEE (printing as 3f8 because the sign bit shifts it > over by one) and 80 for VAX (400, ditto). Yep, sorry, of course it's a factor of 2. My fault :-) > >> So; what happens if we just consider a vax float to be an IEEE float? >> * For add and sub it works just as well; since there is no >> dependency in these ops what the bias is. > > Well, I'd have to check; I'm not sure - but I *think* IEEE reserves two > biased-exponent field values for unusual purposes whereas the VAX > reserves only one. If so, this means that either overflow or > underflow, possibly both, must happen differently. > IEEE has either all bits set (for NaN/Inf), or all bits zero (for 0 or subnormal). See the checks in the small code snippet I wrote. -- Ragge