http://sites.google.com/site/jackokring paper offset.pdf.
Yes the 0 is dead, long live the correct number -1.
3, 2, 1, -1, -1, -3 etc.
100-105=-6 although all positive values are as expected. 0 is not
positive (or negative, a boolean quantity) and is not on the offset
symmetric number line. The 1-x function does sign reversal and logical
negation!
Positive values can be represented in two's complement minus 1
representation so allowing both advantages of the 0 base address
index, and the logical 1 base address index real count. Negative
values are fully symmetric -128 to 128 etc.
Calculus is going to look funny and new. Maybe even integration will
be algorithmic as the dx of 0 does not destroy information, by not
being present maybe.
The half point between 1 and -1 is 0.5. Like the zeta critical line
man.
Does forth do this number system ? Should it?
cheers jacko
Hi
How one treats zero depends on if one is using rectangular or polar
coordinates.
The question of which is right, round toward zero or floored really
depends on how
you measure the world and if you allow offsets.
Absolute zero temperature can't go negative but setting the offset of
freezing
water as zero can.
Dwight
It has nothing to do with rec/pol coordinates...
Zero in the number line is an error. Therefore no zero in the number
line.
Zero only useful for writing numbers, never a zero on its own.
Half way between 1 and -1 is not 0 it is 1/2.
-1 is the first nego-imaginary number. -0.5 does not exist, it is a
synonym for 0.5.
I am talking about removing one unit interval from the number line,
0>=x>-1.
Only positive and negatives occur on the number line. Zero has no sign
and so does not exist.
cheers jacko
I am going to regret this, but my curiosity is overwhelming my
judgement. What does 1 - 1 equal?
-- Charles
Hmm, while the status of 0 is perhaps debatable, the negative numbers
are clearly not natural.
Regards
Emma
> cheers jacko
Easy. He said halfway between 1 and -1 was 1/2, so 1 - 1 = 1/2
Well, I'm confused... He seems to jump willy-nilly between integers and
rationals. In integer arithmetic (as implied by his references to two's
complement notation, what is 1 - 1? (I'm guessing -1?).
-- Charles
-1 one to the left on the new number line. -1 forms the effective
number position of 0. This looks peculiar, but it is consistent and
not in error. It does require going back to first principals to start
with. (1-(1-x))=x showing (1-x) is a self inverse. On the rational
point just as half of 4 is 2, a similar division of the dumber line
segment by two means half of 1 is 1/2.
Strangely the (1-x) of 1/2 is 1/2 and so 1/2 is its own negative.
Numbers between -0 and -1 do not exist. Negation is 180 degree
rotation about the point 1/2. Rationals can also bee two's complement,
as per floats and all positive results are consistent with the usual
expected results, as long as you don't go negative in an intermediate
calculation.
cheers jacko
cheers jacko
I can imagine there are many mappings one can come up with that have
all sorts of interesting properties. I can imagine removing all odd
or even numbers might be useful for something, as would only using
primes. Doing that, you might come up with something terribly clever
that makes some specific algorithm work out lovely, but which makes
99% of everything else numerical hell.
So while I love the assertion-trumps-demonstration arrogance of "zero
is an error; therefore no zero is needed," I think applying your
notion to some real-world problems and showing its superiority would
be a tad more convincing. Show us the practical value of this. This
is the comp.lang.forth newsgroup after all, if if there is one thing
respected by all is practicality.
Fair enough. It is a rationally extendable number field after all, and
any function with a zero would have to be redefined or not be
relevant. I guess the essence is this number field is consistent with
the naturals (quite hard to achieve, as the extension of the naturals
has few ways forward), and is a way of removing the point singularity
at zero. As forth started on astronomical equipment, I assume
astronomical (black hole singularities?) calculations are of interest
to some within the group. Also plank/2?? And symmetry breaking for
electroweak?? The question really was should forth have this number
system? For a lot of people I expect the attachment to zero to be so
strong they would not be interested in a plank scale integer unit and
another number system.
Pure maths always precedes applied maths. It took the zero quite a few
thousand years!
cheers jacko
Fascinating. So for the 0.000000001% of the population that
understands, is concerned with, and actually works on such esoterica,
your freeing mankind from the tyranny of zero sound fabulous.
But I'm still struggling to find the practical application here. So
in my Forth accounting system, let's say I have $100 in an account,
and I buy something for $100. Now I know I have an "attachment" to
zero, but saying I now have fifty cents in my account doesn't seem
like something the bank would go for. Or would I have -$1 in my
account? Somehow the awesomeness of removing zero isn't clear to me.
> Pure maths always precedes applied maths. It took the zero quite a few
> thousand years!
I suggest you pick a favorite picture of yourself now so that when
they come to carve the statue in your honor, you'll be pleased with
the results.
Creating a number system without zero is an interesting idea...
In conventional maths, "zero" is used for two different purposes :
1. as a symbol for "nothing" ( 1 1 - . )
2. as a decimal (or other) number place marker ( #101 )
"Negative numbers" are a shorthand representation for a positive
number combined with a subtraction in place of addition.
Taking your scheme, the Forth to convert to and from your number
system (NonZero format) looks like this :
\ convert from normal to NZ format ( NZ to )
: >NZ ( n -- n' ) dup 0< if 1- then ;
\ convert from NZ format to normal ( NZ from )
: NZ> ( n -- n' ) dup 0= ABORT" No Zero! " dup 0< if 1+ then ;
Unfortunately, this mixes up "zero" with negative numbers - it gets
too confusing.
If you restrict yourself to positive integers, without zero, the
situation gets much easier.
Negative numbers can then be tacked on later as a separate problem.
All that is required is to change the mapping of binary digits to
number So that :
all low bits represents one,
all high bits represent 2**n, where n is the word size in bits :
\ NoZero.f 2009 Sep 30
\ convert from normal to NZ format ( NZ to )
: >NZ ( u -- u' ) 1+ ;
\ convert from NZ format to normal ( NZ from )
: NZ> ( u -- u' ) 1- ;
\ Then all you have to do is to convert all of the maths operations to
use the new NZ number representation :
\ convert two numbers from normal to NZ format ( two NZ to )
: 2NZ> ( nz1 nz2 -- u1 u2 ) NZ> swap NZ> swap ;
\ add two NZ numbers
: NZ+ ( nz nz -- nz' ) 2NZ> + ;
\ subtract two NZ numbers
: NZ- ( nz nz -- nz' ) 2NZ> - ;
\ multiply two NZ numbers
: NZ* ( nz1 nz2 -- nz1*nz2 )
2NZ> >r 0 r> 0 ?do over + loop swap drop >NZ ;
\ raise nz1 to the power of nz2
: NZ** ( nz1 nz2 - nz1**nz2 )
2NZ> >r 1 r> 0 ?do over * loop swap drop >NZ ;
\ print the NZ format number nz
: NZ. ( nz -- ) NZ> . ;
: TTNZ1 cr ." 1 2 + . " 1 >NZ 2 >NZ NZ+ NZ. ;
: TTNZ2 cr ." 2 3 * . " 2 >NZ 3 >NZ NZ* NZ. ;
: TTNZ3 cr ." 3 4 ** . " 3 >NZ 4 >NZ NZ** NZ. ;
: TTall ttnz1 ttnz2 ttnz3 ;
TTall
My gut feeling is that modulo arithmetic will still work, so negative
numbers can be replaced by modular inverses, so everything should
work.
So far so good - but I have a niggling feeling that something big will
stop this being useful...
Everywhere an algorithm would produce zero, you have to catch it and
pass the problem back up to the calling word.
As John said "numerical hell" - but hey, it might just be worth it!
My play time is up now...
Regards
Howerd
Ooops.
Adding the simplest possible test :
: TTNZ4 cr ." 1 1 + . " 1 >NZ 1 >NZ NZ+ NZ. ;
shows that something is not right (it gives 1 as its answer).
I've fixed the code below, but the tests are not exhaustive, and I
think there is a problem with modular arithmetic.
There is something special about 0 (all bits low) as a null value when
added or subtracted, in the way the arithmetic hardware works on a PC.
(I'm testing this using SwiftForth on a PC).
A 32 bit add is a scaled version of a single bit add, where each bit
is either 0 or 1 (low or high), representing the absence or presence
of the value represented by each bit position.
It follows from this that all bits low actually means "zero" i.e.
absence of any value whatsoever.
Conclusion : while it is possible, or even desirable to remove two's
complement negative numbers, all-bits-low-means-zero seems to be a
very elegant way of mapping bits to numbers. It also fits well with
each bit representing a power of 2.
I meant to say in my last post that you can replace "subtract" by
adding (2**n-1) in a modulo n system, and you can replace "divide" by
modular inverse. This means that negative numbers and subtraction are
not necessary. But zero does seem to be valuable.
I think NZ+ (for example) would be hard to implement in hardware
without converting to normal numbers and back, so it would probably be
inefficient.
As a counter argument, arithmetic in Montgomery space is more
efficient for exponentiation, even though you have to convert from and
to normal numbers, so who knows?
Best Regards,
Howerd
This code is better, but far from complete ;)
\ All that is required is to change the mapping of binary digits to
number,
\ so that all low bits represents one,
\ all high bits represent 2**n, where n is the word size in bits :
\ convert from normal to NZ format ( to NZ )
: >NZ ( u -- u' ) 1+ ;
\ convert from NZ format to normal ( NZ from )
: NZ> ( u -- u' ) 1- ;
\ Then all you have to do is to convert all of the maths operations to
use the new NZ number representation :
\ convert two numbers from normal to NZ format ( two to NZ )
: 2>NZ ( u1 u2 -- nz1 nz2 ) >NZ swap >NZ swap ;
\ convert two numbers from NZ format to normal( two NZ from )
: 2NZ> ( nz1 nz2 -- u1 u2 ) NZ> swap NZ> swap ;
\ Then all you have to do is to convert all of the maths operations
that you need to use the new NZ number representation :
\ add two NZ numbers
: NZ+ ( nz nz -- nz' ) 2NZ> 0 ?do 1 + loop >NZ ;
\ subtract two NZ numbers
: NZ- ( nz nz -- nz' ) 2NZ> 0 ?do 1 - loop >NZ ;
\ multiply two NZ numbers
: NZ* ( nz1 nz2 -- nz1*nz2 )
2NZ> >r 0 r> 0 ?do over + loop swap drop >NZ ;
\ raise nz1 to the power of nz2
: NZ** ( nz1 nz2 - nz1**nz2 )
2NZ> >r 1 r> 0 ?do over * loop swap drop >NZ ;
\ print the NZ format number nz
: NZ. ( nz -- ) NZ> . ;
: TTNZ1 cr ." 1 2 + . " 1 >NZ 2 >NZ NZ+ NZ. ;
: TTNZ2 cr ." 2 3 * . " 2 >NZ 3 >NZ NZ* NZ. ;
: TTNZ3 cr ." 3 4 ** . " 3 >NZ 4 >NZ NZ** NZ. ;
: TTNZ4 cr ." 1 1 + . " 1 >NZ 1 >NZ NZ+ NZ. ;
: TTall ttnz1 ttnz2 ttnz3 ttnz4 ;
TTall
Yes a number line missing 0<=x<1, and a separate inversion space
0<=x<1 can make up a rational field. This is by far the most useful
representation, I think.
: NZ+ + 1+ ;
: NZ- - ;
: NZNOT 1 SWAP NZ- ;
: NZ. DUP 0< IF . ELSE 1+ . THEN ;
> But I'm still struggling to find the practical application here. So
> in my Forth accounting system, let's say I have $100 in an account,
> and I buy something for $100. Now I know I have an "attachment" to
> zero, but saying I now have fifty cents in my account doesn't seem
> like something the bank would go for. Or would I have -$1 in my
> account? Somehow the awesomeness of removing zero isn't clear to me.
Yes -$1 in your account and you'd pay interest. As I said most have
such an attachment to zero ;-)
> > Pure maths always precedes applied maths. It took the zero quite a few
> > thousand years!
>
> I suggest you pick a favorite picture of yourself now so that when
> they come to carve the statue in your honor, you'll be pleased with
> the results.
cheers jacko