how JavaScript treats zeros?

E

Evertjan.

Jukka K. Korpela wrote on 30 mei 2011 in comp.lang.javascript:
30.5.2011 10:31, Evertjan. kirjoitti:


It yields false when the value of x is -0.

As it should, -0 is not negative.

If you accept -0 as a specific value,
"being negative" as in "less that 0"
is not the same as "having a negative sign".

I try to see things positively.
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]>
Dr J R Stockton wrote on 29 mei 2011 in comp.lang.javascript:


What is wrong with:

Neg = x < 0

?

Recall that +0 and -0 have the same arithmetic value, are considered
equal by == & ===, and are nonetheless distinguishable by testing their
reciprocals. All IEEE Doubles have signs, in the MSB.

Evaluate x = [-0 < 0 , +0 < 0, -0 == 0 , +0 == 0, -0 > 0 , +0 > 0]

We went into this before, when it took a while for the Vulcan to
comprehend.

In particular, when S is a possibly-signed radix-R fixed-point string,
parseInt(S, R) contains the sign of the value even if the magnitude is
less than 1.0. That sign must be used when the fractional part of the
value represented by S is combined with the integer part. It's easier
to get the sign from the integer part than to see whether the first
significant character is a minus.
 
E

Evertjan.

Dr J R Stockton wrote on 31 mei 2011 in comp.lang.javascript:
In comp.lang.javascript message <Xns9EF560EF24579eejj99@ 194.109.133.242>
Dr J R Stockton wrote on 29 mei 2011 in comp.lang.javascript:


What is wrong with:

Neg = x < 0

?

Recall that +0 and -0 have the same arithmetic value, are considered
equal by == & ===, and are nonetheless distinguishable by testing their
reciprocals. All IEEE Doubles have signs, in the MSB.

Evaluate x = [-0 < 0 , +0 < 0, -0 == 0 , +0 == 0, -0 > 0 , +0 > 0]

var x = [-0 < 0 , +0 < 0, -0 == 0 , +0 == 0, -0 > 0 , +0 > 0];
for (var i=0;i<6;i++)
document.write(x + ', ');

// false, false, true, true, false, false,
We went into this before, when it took a while for the Vulcan to
comprehend.

In particular, when S is a possibly-signed radix-R fixed-point string,
parseInt(S, R) contains the sign of the value even if the magnitude is
less than 1.0. That sign must be used when the fractional part of the
value represented by S is combined with the integer part. It's easier
to get the sign from the integer part than to see whether the first
significant character is a minus.

You are right, ofcourse.

However, while -0 has a minus sign in it's binary storage form,
IT IS NOT NEGATIVE in any logical sense.

So
negValue = x < 0
will do for testing for negative,

while
negSign = -X > 1/X
will give you the sometimas rather meaningless sign.

===============================

Infinite is just a limit,
a final approximation,
even though infinite seems limitless.

Zero also is just a limit,
the final frontier between something and nothing,
which can also be reached from the positive and the negative side of
zero.

My understanding is that -Infinite and +Infinite are also logically the
same. Seen in a graphical way, as straight lines connect in the infinite.

-Infinite and +Infinite
are only pointing to the route to the limit "Infinite".
in the same way that +0 and -0 are poining to the way
that "absolute nothingness" is reached.

That's why 1/-0 goes to -Infinite.

===============================
 
J

Jukka K. Korpela

However, while -0 has a minus sign in it's binary storage form,
IT IS NOT NEGATIVE in any logical sense.

The value -0 has odd features and might be called illogical. But it has
logic of its own. It might be seen as "zero with a history" -
specifically, the history of being reached as the limit of a sequence
converging from the negative side, e.g. of the sequence -1, -1/2, -1/3,
-1/4,...

You also get -0 by multiplying 0 by a negative number.
Infinite is just a limit,
a final approximation,
even though infinite seems limitless.

Eh... poetry? Prosaically, Infinity and -Infinity are two values of type
Number. They can be seen as representing values larger than
Number.MAX_VALUE and smaller than Number_MIN_VALUE, respectively
Zero also is just a limit,

Zero is a number, though the JavaScript 0, like any finite number, may
be seen as corresponding to range of mathematical numbers, due to finite
accuracy. Think about multiplying 1e-300 by itself.
That's why 1/-0 goes to -Infinite.

If you want to have an explanation to why 1/-0 is -Infinite, think about
-0 as explained before. Then 1/-0 can be regarded as the limit of the
series -1, -2, -3, -4,... We don't even need to think of limits in the
calculus sense; we know that at some point, the number in the sequence
gets below Number_MIN_VALUE.
 
E

Evertjan.

Stefan Weiss wrote on 02 jun 2011 in comp.lang.javascript:
Nothing in our normal spectrum of values can be further apart than
infinity and negative infinity. They're infinitely distant from each
other, ...

No, they "are" not, they could only be "seen" as such.

Infinity is not part of "our normal spectrum of values",
it is a limit only to be reached theoretically by approximation.

Just as the difference between +0 and -0 is a limit only to be reached
theory by approximation. for the absolute zero value the sign is
irrilevant.

So I see infinity as the farthest point on a line of values, and seeing
that straight line as a circle has enormous advantages in theoretical
algebra, and in seeing the universum.

So for absolute infinity the sign must by irrilevant too.

You did not answer that. What is so "litteral" about it,
unless you propose a halachical view.

... but there are higher "levels" of infinity than our measly Infinity
or -Infinity. Such infinite sets are said to have a higher cardinality
(beth-one is the cardinality of the continuum, which is equivalent to
the set of rational numbers). In one of the higher cardinalities, it's
theoretically possible to be even more wrong than off-by-infinity ;)

Yes, now you are speaking.

In my vocabulary it is tha aleph-number of infinity.
<http://planetmath.org/encyclopedia/AlephNumbers.html>
<http://planetmath.org/?op=getobj&from=objects&name=BethNumbers>

It is a theoretical possibility to use your view, and one to use mine.

I would not bring any rationality into that.

"Safety in numbers" is another matter. [Netherlands: Between 1980 and 2005,
cycling increased by 45%, and cyclist fatalities decreased by 58%.]
<http://en.wikipedia.org/wiki/Safety_in_numbers>

Following that hypothesis would only positive infinity be totally safe,
and negative infinity lead to a certain mishap?
It was just a joke. You can safely ignore everything I wrote.

I could ignore anything you wrote anyway,
but there would be no fun in that.

But safely? The continuum-hypothesis would suffer.
 
S

Scott Sauyet

Stefan Weiss said:
It was just a joke. You can safely ignore everything I wrote.

Don't worry, I for one laughed. Now for a round of math-nerds singing
"Aleph-naught bottles of beer on the wall!"

-- Scott
 
D

Dr J R Stockton

Wed said:
You also get -0 by multiplying 0 by a negative number.

Only if the multiplicand is +0. 1/(-0 * -0) -> Infinity, so the product
is positive zero..


EjH : From memory, there are two interpretations of numbers; one in
which +Infinity is the same as -Infinity, and one in which it is not.
One of those is called "affine" and the other is called something else.
 
T

Thomas 'PointedEars' Lahn

Jukka said:
Eh... poetry? Prosaically, Infinity and -Infinity are two values of type
Number. They can be seen as representing values larger than
Number.MAX_VALUE and smaller than Number_MIN_VALUE, respectively


Zero is a number, though the JavaScript 0, like any finite number, may
be seen as corresponding to range of mathematical numbers, due to finite
accuracy. Think about multiplying 1e-300 by itself.


If you want to have an explanation to why 1/-0 is -Infinite, think about
-0 as explained before. Then 1/-0 can be regarded as the limit of the
series -1, -2, -3, -4,... We don't even need to think of limits in the
calculus sense; we know that at some point, the number in the sequence
gets below Number_MIN_VALUE.

Please define Number_MIN_VALUE.


PointedEars
 
E

Evertjan.

Dr J R Stockton wrote on 02 jun 2011 in comp.lang.javascript:
EjH : From memory, there are two interpretations of numbers; one in
which +Infinity is the same as -Infinity, and one in which it is not.
One of those is called "affine" and the other is called something else.

See my posting, I said "my interpretation is".

On which Stephan said I was wrong, which is nonsense,
because at least I was right in stating what my interpretation was and is.

The implementation of Javascript storing +0 and -0,
but not being able to recall the difference but by devious means,
such as 0/-0, seems a serious implementation and specification flaw.

If we had a direct conversion from stored value to binary content of that
value, then perhaps my view would be different.
there are two interpretations of numbers

I wouldn't call infinity a number.

btw, what about:
in a 2-dimensional world 2 straight lines always interconnect,
2 parallel straight lines do so at infinity,
as a 2-dimensional world is not an infinite square.
 
S

SteveYoungTbird

btw, what about:
in a 2-dimensional world 2 straight lines always interconnect, Why?
2 parallel straight lines do so at infinity,
Surely 2 parallel straight lines never interconnect, even in Flatland.
 
E

Evertjan.

SteveYoungTbird wrote on 03 jun 2011 in comp.lang.javascript:

Because they touch at infinity.
All other interconnections are crossings,
unless two lines are exact duplicates.
Because a two dimentional space is not a square where the distance from
here [origo] to the diagonal infinity is not farther away than the
horizontal or the vertical infinity.

Independent of that, why not?

Surely 2 parallel straight lines never interconnect, even in Flatland.

Maybe that is your gut feeling,
but mathematics can be as convoluted as your gut.

See!
 
S

SteveYoungTbird

SteveYoungTbird wrote on 03 jun 2011 in comp.lang.javascript:

Because they touch at infinity.
All other interconnections are crossings,
unless two lines are exact duplicates.
Because a two dimentional space is not a square where the distance from
here [origo] to the diagonal infinity is not farther away than the
horizontal or the vertical infinity.

Independent of that, why not?

Poster-1: In 16 dimensional space 2 + 4 = 23.
Poster-2: Why?
Poster-1: Why not?
It doesn't really convince does it?
Maybe that is your gut feeling,
but mathematics can be as convoluted as your gut.

Can you offer any mathematical proof of your assertion that parallel
lines interconnect in a 2 dimensional world?
No.
 
E

Evertjan.

SteveYoungTbird wrote on 03 jun 2011 in comp.lang.javascript:
SteveYoungTbird wrote on 03 jun 2011 in comp.lang.javascript:
On 06/03/2011 09:26 AM, Evertjan. wrote:

btw, what about:
in a 2-dimensional world 2 straight lines always interconnect,

Because they touch at infinity.
All other interconnections are crossings,
unless two lines are exact duplicates.
Because a two dimentional space is not a square where the distance from
here [origo] to the diagonal infinity is not farther away than the
horizontal or the vertical infinity.

Independent of that, why not?

Poster-1: In 16 dimensional space 2 + 4 = 23.
Poster-2: Why?
Poster-1: Why not?
It doesn't really convince does it?

This is not part of the thread.
Convincing someone is not the final goal of discussion.
Can you offer any mathematical proof of your assertion that parallel
lines interconnect in a 2 dimensional world?

Is there any proof to the contrary?

Remember we are discussing the infinite, not a tangible part of space.

It is just an extension of reality to be defined,
and making them touch is usefull.

I thought so.
My "see" points to that.
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]>,
Jukka K. Korpela wrote:

Please define Number_MIN_VALUE.

I expect it is Number.MIN_VALUE, with a typo, and therefore about
5E-324.

J = 1 ; while (J/=2) K = J ; K -> 5e-324


I have a vague recollection that there may be a bit in the PC FPU which
chooses between affine and non-affine arithmetic; but ECMAScript has no
access to it.
 
S

SteveYoungTbird

SteveYoungTbird wrote on 03 jun 2011 in comp.lang.javascript:
SteveYoungTbird wrote on 03 jun 2011 in comp.lang.javascript:

On 06/03/2011 09:26 AM, Evertjan. wrote:

btw, what about:
in a 2-dimensional world 2 straight lines always interconnect,

Why?

Because they touch at infinity.
All other interconnections are crossings,
unless two lines are exact duplicates.
Because a two dimentional space is not a square where the distance from
here [origo] to the diagonal infinity is not farther away than the
horizontal or the vertical infinity.

Independent of that, why not?

Poster-1: In 16 dimensional space 2 + 4 = 23.
Poster-2: Why?
Poster-1: Why not?
It doesn't really convince does it?

This is not part of the thread.
Convincing someone is not the final goal of discussion.
Can you offer any mathematical proof of your assertion that parallel
lines interconnect in a 2 dimensional world?

Is there any proof to the contrary?

The burden of proof is on the one making the assertion. Proving a
negative is often impossible but that doesn't mean the assertion is
true. I cannot prove that there isn't a pink whale in orbit around
Saturn but that doesn't mean there is.
Remember we are discussing the infinite, not a tangible part of space.
It is just an extension of reality to be defined,
and making them touch is usefull.

Making them not touch could also be useful.

A 2-dimensional world doesn't have to be a square, it could be a
pentagon or an octagon or a circle.
I thought so.
My "see" points to that.

I guess that makes you very clever then.
 
T

Thomas 'PointedEars' Lahn

Dr said:
Thomas 'PointedEars' Lahn posted:

I expect it is Number.MIN_VALUE, with a typo, and therefore about
5E-324.

Hence my asking, because the statement above would be false then (it is a
common misconception that Number.MIN_VALUE was -Number.MAX_VALUE.)
J = 1 ; while (J/=2) K = J ; K -> 5e-324

That does not appear to have anything to do with Jukka's statement, though.


PointedEars
 
T

Thomas 'PointedEars' Lahn

Hopefully to put this off-topic "discussion" to a quick end:

The world (i.e. space) does not have to be two-dimensional for that to be
true. It only has to be governed by the rules of projective geometry.
Why?

Because they touch at infinity.
All other interconnections are crossings,
unless two lines are exact duplicates.
Because a two dimentional space is not a square where the distance
from here [origo] to the diagonal infinity is not farther away than the
horizontal or the vertical infinity.

Independent of that, why not?

Poster-1: In 16 dimensional space 2 + 4 = 23.
Poster-2: Why?
Poster-1: Why not?
It doesn't really convince does it?

Fallacy: Reductio ad absurdum.

Fallacy: Red herring.

Ad-hominem/genetic fallacy.

Yes. (See e.g. said:
The burden of proof is on the one making the assertion. Proving a
negative is often impossible but that doesn't mean the assertion is
true. I cannot prove that there isn't a pink whale in orbit around
Saturn but that doesn't mean there is.

ACK (observed fallacy: shifting the burden of proof).
Making them not touch could also be useful.

That looks like a naturalistic fallacy. Obviously the apparent "usefulness"
of something is not a suitable criterion to judge its existence or
correctness.
A 2-dimensional world doesn't have to be a square, it could be a
pentagon or an octagon or a circle.

That would still be a limited space, which was the (so far poorly made)
point: If you are talking about infinities (as we did), then there are no
limits to the space, and you have to accept that there are geometries in
which parallel lines meet (any non-Euclidean geometry allows that, however,
e.g. meridians all meet at the poles), and at least one (projective
geometry) in which they meet at infinity.¹ Given that, in this geometry
*all* lines MUST meet in infinity (because the only alternative is that they
intersect before, which means they are not parallels). (Not so in Euclidean
geometry, which you are referring to.)

_____
¹ One practical application of that is the description of perspective:
The sides of the road ahead, although we know that they are more or less
parallel to one another, look narrower under projection as farther they
are away, and appear to meet at some point of infinite distance to the
observer. See also the first image right-hand side at
<http://en.wikipedia.org/wiki/Projective_space>.


HTH

PointedEars
 
L

Lasse Reichstein Nielsen

SteveYoungTbird said:
Can you offer any mathematical proof of your assertion that parallel
lines interconnect in a 2 dimensional world?

He's probably talking about an extension of the real plance, e.g.,
http://en.wikipedia.org/wiki/Line_at_infinity
as if it's the only possible model.

You can make mathematical models that have the properties that was
given - but it's not the only possible models.

/L
 
J

Jukka K. Korpela

4.6.2011 2:26 said:
Hopefully to put this off-topic "discussion" to a quick end:

The way to put off-topic "discussions" to an end is to stop posting
off-topic "comments". But you seem to have chosed to keep posting long
off-topic "comments", in a manner that has apparently been crafted to
provoke further "discussion".

F'ups set.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,075
Messages
2,570,562
Members
47,197
Latest member
NDTShavonn

Latest Threads

Top