For some reason, I've been dreaming about negative numbers lately. I think they deserve their own number set notation.
For some reason, I've been dreaming about negative numbers lately. I think they deserve their own number set notation.
Now, there's an exponent and a fraction, too. I've been playing around with how to do these numbers with logic gates (and verilog!) and you can either two's complement the whole thing and work with absolute values, or you can keep the fraction part as a two's complement...
So I just redid multiplication using two's complemented fractions! And addition/subtraction too, which for floating points in general is significantly harder than multiplication. The nice thing about two's complemented floating points is you don't need separate algorithms for addition and subtraction; you can just do everything with one algorithm.
If you liked that lecture, I'm already starting on some verilog implementations.
This is an example multiplication 8 bit * 8 bit -> 16 bit unpacked (20 bits). It differs from standard floating point in that the fractions are stored as two's complement. It takes a little bit of wrapping your head around, but the hidden bit for negative numbers is actually -2 ! Moment of zen.
https://github.com/interplanetary-robot/mullinengine/blob/ma...
Has there been much traction for getting major chip manufacturers to implement this? I know they're all looking for the next big thing and Intel is working on specialized neuromorphic chips. A general "drop-in" replacement for floating point seems like an opportunity for a general-purpose win from low-hanging fruit:
Intel Gets Serious About Neuromorphic, Cognitive Computing Future https://news.ycombinator.com/item?id=13623846
I do have a hardware architecture in mind for how to very effectively and efficiently execute machine learning calculations using posits.
How efficient do you think regular C or GPU code (on existing hardware) can be made for compressing a 32-bit float to e.g. a 16-bit posit, and for expanding the posit back into a 32-bit float?
To actually do computation I would convert the posits back into 32-bit floats (or e.g. in the Javascript case, 64-bit floats), and then take the inverse stereographic projection.
[Stereographic projection is extremely cheap; for each data point only requires one division and some additions and multiplications.]
I’ll do some experimenting at some point.
Edit: Well. I see it would result in losing the values 0 and 1. Another question: Since it is fixed length of 4 bits (for N=32) why don't we just extract the 4 bit value, then we could represent 2^4 regimes this time without losing 0 and 1.
In my software posit library (which is intentionally strictly binary and not backended by IEEE floats), (https://github.com/interplanetary-robot/SigmoidNumbers) I did everything by first inverting negative numbers and doing decode in the positive domain.
As I design the hardware, it's actually better to NOT do a two's complement inversion to do the decode, and keep the fraction as two's complement!
Also the 4 bit posit was just a simplification to help you understand the structure from a constructive point of view. posits can be of arbitrary length; they have a property I call isomorphic - so appending zeros exactly preserves the value of a short posit when increased in length; conversely, rounding a long posit to a shorter one reports the "nearest representable value".
http://web.stanford.edu/class/ee380/Abstracts/170201-slides....
I never understood why complex numbers are considered one. I mean, yes they "are" a set, but besides that they are completely different.
All number sets I learned about did fill some gaps in one dimension, but complex numbers somehow added a new dimension.
Like real numbers stood in an entirely different context to rational numbers than complex numbers stood to real numbers.
In my head a one dimensional thing like R is fundamentally different from a multidimensional thing like C.
Edit: FWIW, I consider the terminology of 'real' vs 'imaginary' completely stupid and misleading. This terminology didn't really make it to other languages, e.g. in Russian it's 'material' vs 'complex' numbers, but they don't use the term 'imaginary'.