Live data from Hacker News

16-bit math look-up tables – the unexpected power of scaled-integer math

wilsonminesco.com

41–50 of 54 posts

Re: 16-bit math look-up tables – the unexpected power of scaled-integer math

#41

Earlier quoted context omitted.

I think I would probably choose to have one NaN rather than +/-Infinity. Infinity itself is not a number -- it's just a special NaN.

Infinity is certainly a “number”; https://en.wikipedia.org/wiki/Projectively_extended_real_lin... https://en.wikipedia.org/wiki/Riemann_sphere

> In real analysis, the projectively extended real line [...] is the extension of the number line by a point denoted ∞.

> The extended complex numbers consist of the complex numbers C together with ∞.

It may be an "extended number", but it is not a number.

Re: 16-bit math look-up tables – the unexpected power of scaled-integer math

#42

For those who are interested, CORDIC (for COordinate Rotation DIgital Computer) is another technique from that era. It "is a simple and efficient algorithm to calculate hyperbolic and trigonometric functions, typically converging with one digit (or bit) per iteration." See https://en.wikibooks.org/wiki/Digital_Circuits/CORDIC For instructional purposes, here is a simple Python implementation that uses only adds and s…

IIRC, CORDIC has some issues as you scale the number of bits you want--you can't just run CORDIC 64 times for 64-bits of accuracy, for example.

I think the point of diminishing returns is 14-16 bits, but it's been a long time and I'd be happy to be proven wrong.

Re: 16-bit math look-up tables – the unexpected power of scaled-integer math

#43

Earlier quoted context omitted.

Infinity is certainly a “number”; https://en.wikipedia.org/wiki/Projectively_extended_real_lin... https://en.wikipedia.org/wiki/Riemann_sphere

> In real analysis, the projectively extended real line [...] is the extension of the number line by a point denoted ∞. > The extended complex numbers consist of the complex numbers C together with ∞. It may be an "extended number", but it is not a number.

If you can consider a “complex number” or a “transcendental number” to be a “number”, then there’s really no reason to not also consider ∞ to be a number.

In general, the boundary of the category of ideas (if you like, elements of some formal model) that can be called “numbers” is a very fuzzy and arbitrary one.

Some people might reject as “numbers” anything other than the counting numbers 1, 2, 3, 4. Others might allow “negative numbers” or ratios. Still others are happy to include quaternions or infinite strings of digits output by some computer program. Meh.

Re: 16-bit math look-up tables – the unexpected power of scaled-integer math

#44
post #32

Earlier quoted context omitted.

Infinity is certainly a “number”; https://en.wikipedia.org/wiki/Projectively_extended_real_lin... https://en.wikipedia.org/wiki/Riemann_sphere

It's not a number if you are like me and say "a number is an element of a ring." (We're not talking about ordinals or cardinals, the subject being rationals, otherwise I might have a different definition.) The projectively extended real line doesn't support adding infinity to itself, which is what the grandparent to your comment was talking about. The problem is that the projectively extended real line does not have…

Polynomials are numbers now? :-)

Re: 16-bit math look-up tables – the unexpected power of scaled-integer math

#45
post #32

Earlier quoted context omitted.

It's not a number if you are like me and say "a number is an element of a ring." (We're not talking about ordinals or cardinals, the subject being rationals, otherwise I might have a different definition.) The projectively extended real line doesn't support adding infinity to itself, which is what the grandparent to your comment was talking about. The problem is that the projectively extended real line does not have…

Polynomials are numbers now? :-)

Mainly, I was poking a bit of fun at the idea that "number" even has a rigorous definition. You can't really assert whether infinity is a number or not without 1) knowing what they mean by "number" or 2) knowing what they mean by "infinity." If you want "numbers" to be a field extension of the reals and you want it to contain an "infinity," then the hyperreal numbers might be appropriate [1]. If you are instead content with having an infinitesimal and having only a ring extension, then the dual numbers might be appropriate [2].

[1] https://en.wikipedia.org/wiki/Hyperreal_number [2] https://en.wikipedia.org/wiki/Dual_number

But, anyway, if you can claim infinity is a number because someone thought of the real projective line, I can say polynomials are numbers. Square matrices, too --- I think of square matrices as being big numbers; rank measures how invertible a big number is.

A stranger consequence of my definition is that a continuous real-valued function on a space X is a "number." If X is a single point, then such a function is the same as a real number. If X is a discrete set of n points, then the set of functions is R^n. If X is compact (I think that's sufficient?) then the maximal ideals in the set of continuous functions is in correspondence with X itself. This suggests that for any ring, one may imagine there to be a space that it is the functions of, whose points are the maximal ideals of that ring. For the ring of complex one-variable polynomials, the points correspond to C itself (the maximal ideals are generated by (x-c) for varying constants c). So, yeah, polynomials are numbers now.

Re: 16-bit math look-up tables – the unexpected power of scaled-integer math

#46

Earlier quoted context omitted.

Construction of a unit complex number though, given an angle, requires trigonometry. Precomputing this and re-using it is identical to precomputing the sine and cosine of that angle and reusing them instead - the complex number itself doesn't simplify anything here other than storing both the sine and cosine in one variable.

I don't quite agree. Complex analysis is more than powerful enough to recover the unit complex number corresponding to a specific angle without referencing any kind of trigonometry. Of course you'll have reconstructed the sine and cosine functions that way, but you don't need to use a single trigonometric function or theorem to get there.

In terms of implementation, what are you not quite agreeing with?

Re: 16-bit math look-up tables – the unexpected power of scaled-integer math

#47
post #45

Earlier quoted context omitted.

Polynomials are numbers now? :-)

Mainly, I was poking a bit of fun at the idea that "number" even has a rigorous definition. You can't really assert whether infinity is a number or not without 1) knowing what they mean by "number" or 2) knowing what they mean by "infinity." If you want "numbers" to be a field extension of the reals and you want it to contain an "infinity," then the hyperreal numbers might be appropriate [1]. If you are instead conte…

[deleted]

Re: 16-bit math look-up tables – the unexpected power of scaled-integer math

#48
post #4

Earlier quoted context omitted.

If you're interpolating and only need 16 bits of precision, you need only a small table. 32 or 64 entries should be enough for sine and cosine.

It’s probably a generally better idea to use a polynomial approximation if you have a floating point unit; a degree 8 polynomial for sin(x) on the range [0, π /2] gets you to just about the limits of single precision floating point. If you only need about 4 digits of precision, you can use a degree 5 polynomial.

FWIW, Applesoft for the 6502 uses a 5th order poly.

Re: 16-bit math look-up tables – the unexpected power of scaled-integer math

#50
post #29

Earlier quoted context omitted.

indeed, I was using fixed point maths on PlayStation 1 games in the mid to late 90s. It was often responsible for the gaps you'd see between polygons on many PS1 games.

I was using it for z-80, game boy color homebrew. Getting down in the bits like this is.... bracing!

I remember doing a Gameboy Color game after working on a PS1 title. And even though I came from an 8 bit 6502 background (BBC Micro), going back to it was hell. 'Bracing' is an understatement! I couldn't imagine much worse these days.
Post reply on HN