Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #26110 > unrolled thread

Date arithmetic

Started bySwifty <steve.j.swift@gmail.com>
First post2014-11-11 12:38 +0000
Last post2014-11-14 04:34 +0100
Articles 20 on this page of 97 — 16 participants

Back to article view | Back to comp.lang.javascript


Contents

  Date arithmetic Swifty <steve.j.swift@gmail.com> - 2014-11-11 12:38 +0000
    Re: Date arithmetic "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-11-11 15:10 +0100
      Re: Date arithmetic Swifty <steve.j.swift@gmail.com> - 2014-11-11 22:07 +0000
        Re: Date arithmetic Tim Streater <timstreater@greenbee.net> - 2014-11-11 22:37 +0000
          Re: Date arithmetic "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-12 02:40 +0100
            Re: Date arithmetic "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-11-12 08:21 +0100
              Re: Date arithmetic "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-13 15:27 +0100
                Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-13 21:26 +0100
                  Re: Date arithmetic "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-14 14:16 +0100
                    Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-15 07:13 +0100
                    Re: Date arithmetic Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-11-15 19:36 +0000
                      Re: Date arithmetic "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-16 17:24 +0100
                        Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-16 18:49 +0100
                          Re: Date arithmetic "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-17 00:14 +0100
                        Re: Date arithmetic Dr J R Stockton <J.R.Stockton@physics.org> - 2014-11-16 10:51 -0800
                          Re: Date arithmetic "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-11-16 20:17 +0100
                          Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-17 00:52 +0100
                            Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-17 01:11 +0100
                              Re: Date arithmetic Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-11-18 16:18 +0000
                                Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-19 11:00 +0100
                                  Re: Date arithmetic Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-11-21 22:58 +0000
                                    Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-22 18:33 +0100
                                      Re: Date arithmetic Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-11-23 19:38 +0000
                                        Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-24 01:14 +0100
                                          Re: Date arithmetic Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-11-25 21:17 +0000
                                            Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-26 18:25 +0100
                                              Re: Date arithmetic Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-11-27 19:34 +0000
                                                Re: Date arithmetic "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-28 01:25 +0100
                                                  Re: Date arithmetic Dr J R Stockton <J.R.Stockton@physics.org> - 2014-11-28 05:29 -0800
                                                Re: Date arithmetic Andrew Poulos <ap_prog@hotmail.com> - 2014-11-28 11:44 +1100
                                                  Re: Date arithmetic Dr J R Stockton <J.R.Stockton@physics.org> - 2014-11-28 04:52 -0800
                                                    Re: Date arithmetic "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-28 14:24 +0100
                                                    Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-28 14:47 +0100
                                                      Re: Date arithmetic Dr J R Stockton <J.R.Stockton@physics.org> - 2014-11-28 06:12 -0800
                                                        Re: Date arithmetic Andrew Poulos <ap_prog@hotmail.com> - 2014-11-29 16:59 +1100
                                                          Re: Date arithmetic John Harris <niam@jghnorth.org.uk.invalid> - 2014-11-29 20:05 +0000
                                                            Re: Date arithmetic Joao Rodrigues <groups_jr-1@yahoo.com> - 2014-11-29 23:47 -0200
                                                            Re: Date arithmetic Andrew Poulos <ap_prog@hotmail.com> - 2014-12-01 10:44 +1100
                                                              Re: Date arithmetic Tim Streater <timstreater@greenbee.net> - 2014-11-30 23:54 +0000
                                                                Re: Date arithmetic Andrew Poulos <ap_prog@hotmail.com> - 2014-12-01 13:01 +1100
                            Re: Date arithmetic "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-17 01:34 +0100
                              Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-17 01:41 +0100
                                Re: Date arithmetic "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-18 19:06 +0100
                              Re: Date arithmetic Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-11-18 16:26 +0000
                                Re: Date arithmetic "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-19 17:52 +0100
                                  Re: Date arithmetic Gene Wirchenko <genew@telus.net> - 2014-11-19 09:44 -0800
                                    Re: Date arithmetic "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-11-19 19:34 +0100
                                      Re: Date arithmetic Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-11-19 19:13 +0000
                                        Re: Date arithmetic "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-11-19 22:18 +0100
                                          Re: Date arithmetic Gene Wirchenko <genew@telus.net> - 2014-11-19 13:43 -0800
                                          Re: Date arithmetic Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-11-19 22:40 +0000
                                            Re: Date arithmetic Tim Streater <timstreater@greenbee.net> - 2014-11-19 22:51 +0000
                                              Re: Date arithmetic Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-11-19 23:35 +0000
                                        Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-19 23:10 +0100
                                        Re: Date arithmetic Tim Streater <timstreater@greenbee.net> - 2014-11-19 22:32 +0000
                                          Re: Date arithmetic Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-11-19 23:26 +0000
                                            Re: Date arithmetic "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-20 00:47 +0100
                                              Re: Date arithmetic Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-11-20 00:17 +0000
                                            Re: Date arithmetic Dr J R Stockton <J.R.Stockton@physics.org> - 2014-11-20 01:18 -0800
                                              Re: Date arithmetic Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-11-20 13:47 +0000
                                          Re: Date arithmetic Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-11-21 22:29 +0000
                                      Re: Date arithmetic Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-11-19 19:24 -0200
                                        Re: Date arithmetic Gene Wirchenko <genew@telus.net> - 2014-11-19 13:40 -0800
                                    Re: Date arithmetic "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-19 23:40 +0100
                            Re: Date arithmetic Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-11-18 16:44 +0000
                              Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-19 11:20 +0100
                  Re: Date arithmetic Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-11-14 20:45 +0000
                  Re: Date arithmetic "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2014-11-15 14:13 -0800
                    Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-15 23:42 +0100
        Re: Date arithmetic "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-11-12 00:23 +0100
        Re: Date arithmetic Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-11-12 13:24 +0000
          Re: Date arithmetic "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-12 14:43 +0100
            Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-12 19:48 +0100
              Re: Date arithmetic "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-13 01:18 +0100
            Re: Date arithmetic Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-11-12 20:19 +0000
              Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-13 03:42 +0100
      Re: Date arithmetic Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-11-12 20:06 +0000
      Re: Date arithmetic RobG <rgqld@iinet.net.au> - 2014-11-23 20:51 -0800
        Re: Date arithmetic Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-11-25 20:08 +0000
          Re: Date arithmetic "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-26 01:31 +0100
          Re: Date arithmetic RobG <rgqld@iinet.net.au> - 2014-12-08 19:42 -0800
        Re: Date arithmetic "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-26 01:40 +0100
        Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-26 22:07 +0100
          Re: Date arithmetic RobG <rgqld@iinet.net.au> - 2014-12-08 21:41 -0800
            Re: Date arithmetic "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-12-09 09:47 +0100
            Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-12-09 14:17 +0100
            Re: Date arithmetic Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-12-10 23:34 +0000
              Re: Date arithmetic RobG <rgqld@iinet.net.au> - 2014-12-10 17:21 -0800
                Re: Date arithmetic Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-12-13 17:19 +0000
            Re: Date arithmetic RobG <rgqld@iinet.net.au> - 2014-12-10 18:35 -0800
    Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-11 22:29 +0100
      Re: Date arithmetic Swifty <steve.j.swift@gmail.com> - 2014-11-11 21:53 +0000
        Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-11 23:43 +0100
          Re: Date arithmetic John Harris <niam@jghnorth.org.uk.invalid> - 2014-11-12 15:49 +0000
    Re: Date arithmetic Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-11-12 19:58 +0000
    Re: Date arithmetic Dr.Kral@nyc.rr.com - 2014-11-13 20:24 -0500
      Re: Date arithmetic Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-14 04:34 +0100

Page 3 of 5 — ← Prev page 1 2 [3] 4 5  Next page →


#26152

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2014-11-17 01:34 +0100
Message-ID<m4bfqm$7lo$1@solani.org>
In reply to#26150
Thomas 'PointedEars' Lahn wrote:

> Dr J R Stockton wrote:
> 
>> You mean days between February and January in that order.
> 
> No, he means what he wrote, and, with the exception of the use of “between” 
> (which should be “from”, and month names are always capitalized), I concur.

It seems to me that "between ... and" is open to interpretation.  I
meant the closed interval [March, December] (as used in SQL's between
... and), John the open interval ]February, January[ (January of the
following year).  Obviously, both are the same.  If I had written "from
March to December", the confusion probably would have been avoided
(thanks for the pointer).

>> Unsubtle.  The first part of the expression seems derived from, but does
>> not take full benefit from, Zeller's Congruence
> 
> Interesting.  If it has not already happened and proves to be correct, this 
> information should be added as reference to the Wikipedia article I took the 
> approach from.

ACK.

>> But we know that Swifty wants to process his _hand-entered_ dates.
>> A quick test in current Firefox on an elderly PC shows that it executes a
>> million of 'new Date()' in about 2.2 seconds.  So there can be no
>> perceptible advantage in doing anything other than 'new Date()' on each
>> input, subtracting, dividing by 864e5, and rounding to integer, to get
>> Swifty his date difference.
> 
> You are missing the point and are preaching to the choir.  It has already 
> been stated twice (at least) in this thread that for this use-case the 
> approach in jsx.date.getDayOfYear() is not the most efficient one, and that 
> the division approach is probably the best one.  After all, it was Christoph 
> who suggested it first, in this thread at least.

That is not correct.  It has been Evertjan to first suggest the division
in this thread[1] (if I'm not mistaken).  My suggestion was meant to
avoid any potential DST related issues, and to stick with proper integer
calculations (what might be somewhat dangerous considering that
ECMAScript Numbers are floating point values).

[1] <news:XnsA3E354F8EA950eejj99@194.109.133.133>

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#26153

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2014-11-17 01:41 +0100
Message-ID<4619702.bvc2cBK1RH@PointedEars.de>
In reply to#26152
Christoph M. Becker wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Dr J R Stockton wrote:
>>> It has already been stated twice (at least) in this thread that for this
>>> use-case the approach in jsx.date.getDayOfYear() is not the most
>>> efficient one, and that the division approach is probably the best one. 
>>> After all, it was Christoph who suggested it first, in this thread at
>>> least.
> 
> That is not correct.  It has been Evertjan to first suggest the division
> in this thread[1] (if I'm not mistaken).

According to my newsreader, you are correct.  But it was not his suggestion 
I was referring to with “division approach”:

> My suggestion was meant to avoid any potential DST related issues, and to
> stick with proper integer calculations (what might be somewhat dangerous
> considering that ECMAScript Numbers are floating point values).
> 
> [1] <news:XnsA3E354F8EA950eejj99@194.109.133.133>

See my clarification in <news:40469088.RWZSUOfdCW@PointedEars.de>, which 
will probably have been distributed to you at the time you read this 
message.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#26154

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2014-11-18 19:06 +0100
Message-ID<m4g1rd$l3a$3@solani.org>
In reply to#26153
Thomas 'PointedEars' Lahn wrote:

> See my clarification in <news:40469088.RWZSUOfdCW@PointedEars.de>, which 
> will probably have been distributed to you at the time you read this 
> message.

Ah, I see.  Thanks for the clarification. :)

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#26156

FromDr J R Stockton <reply1400@merlyn.demon.co.uk.invalid>
Date2014-11-18 16:26 +0000
Message-ID<sTmTP8e4M3aUFwP1@invalid.uk.co.demon.merlyn.invalid>
In reply to#26152
In comp.lang.javascript message <m4bfqm$7lo$1@solani.org>, Mon, 17 Nov
2014 01:34:25, Christoph M. Becker <cmbecker69@arcor.de> posted:

>My suggestion was meant to
) ...,
>and to stick with proper integer
>calculations (what might be somewhat dangerous considering that
>ECMAScript Numbers are floating point values).


The Date range has been chosen such that every millisecond within the
range is represented exactly in an ECMAScript float.  One only needs to
be careful not to multiply and get a result outside the allotted 10^8
days.

-- 
 (c) John Stockton, nr London UK        Reply address via Merlyn Home Page.
   news:comp.lang.javascript FAQ <http://www.jibbering.com/faq/index.html>.
   <http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
   <http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

[toc] | [prev] | [next] | [standalone]


#26162

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2014-11-19 17:52 +0100
Message-ID<m4ihsi$nm9$1@solani.org>
In reply to#26156
Dr J R Stockton wrote:

> In comp.lang.javascript message <m4bfqm$7lo$1@solani.org>, Mon, 17 Nov
> 2014 01:34:25, Christoph M. Becker <cmbecker69@arcor.de> posted:
> 
>> My suggestion was meant to
> ) ...,
>> and to stick with proper integer
>> calculations (what might be somewhat dangerous considering that
>> ECMAScript Numbers are floating point values).
> 
> 
> The Date range has been chosen such that every millisecond within the
> range is represented exactly in an ECMAScript float.  One only needs to
> be careful not to multiply and get a result outside the allotted 10^8
> days.

ACK -- assuming that there are no implementation errors.  I rarely do
float calculations in ECMAScript implementations, so I don't know if
this assumption is reasonable.  Probably it is.

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#26163

FromGene Wirchenko <genew@telus.net>
Date2014-11-19 09:44 -0800
Message-ID<knlp6a9uast6icgb6mkf8l964d3gjbdbge@4ax.com>
In reply to#26162
On Wed, 19 Nov 2014 17:52:40 +0100, "Christoph M. Becker"
<cmbecker69@arcor.de> wrote:

[snip]

>ACK -- assuming that there are no implementation errors.  I rarely do
>float calculations in ECMAScript implementations, so I don't know if
>this assumption is reasonable.  Probably it is.

     Since it is the only number type available for variables, how do
you avoid it?

Sincerely,

Gene Wirchenko

[toc] | [prev] | [next] | [standalone]


#26164

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2014-11-19 19:34 +0100
Message-ID<XnsA3EAC729338EBeejj99@194.109.133.133>
In reply to#26163
Gene Wirchenko <genew@telus.net> wrote on 19 nov 2014 in 
comp.lang.javascript:

> On Wed, 19 Nov 2014 17:52:40 +0100, "Christoph M. Becker"
> <cmbecker69@arcor.de> wrote:
> 
> [snip]
> 
>>ACK -- assuming that there are no implementation errors.  I rarely do
>>float calculations in ECMAScript implementations, so I don't know if
>>this assumption is reasonable.  Probably it is.
> 
>      Since it is the only number type available for variables, 

What about integers?

> how do you avoid it?
> 
> Sincerely,
> 
> Gene Wirchenko
> 



-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#26165

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2014-11-19 19:13 +0000
Message-ID<877fyr3sxr.fsf@bsb.me.uk>
In reply to#26164
"Evertjan." <exxjxw.hannivoort@inter.nl.net> writes:

> Gene Wirchenko <genew@telus.net> wrote on 19 nov 2014 in 
> comp.lang.javascript:
>
>> On Wed, 19 Nov 2014 17:52:40 +0100, "Christoph M. Becker"
>> <cmbecker69@arcor.de> wrote:
>> 
>> [snip]
>> 
>>>ACK -- assuming that there are no implementation errors.  I rarely do
>>>float calculations in ECMAScript implementations, so I don't know if
>>>this assumption is reasonable.  Probably it is.
>> 
>>      Since it is the only number type available for variables, 
>
> What about integers?

ECMAScript does not have a separate integer type.  You can represent any
integer in (2^53, 2^53) exactly (and zero twice!) using the built-in
Number type, but you are still using a floating point type as far as the
language definition goes.

<snip>
-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#26166

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2014-11-19 22:18 +0100
Message-ID<XnsA3EAE2E07B3D9eejj99@194.109.133.133>
In reply to#26165
Ben Bacarisse <ben.usenet@bsb.me.uk> wrote on 19 nov 2014 in 
comp.lang.javascript:

>>>      Since it is the only number type available for variables, 
>>
>> What about integers?
> 
> ECMAScript does not have a separate integer type.  You can represent any
> integer in (2^53, 2^53) exactly (and zero twice!) using the built-in
> Number type, but you are still using a floating point type as far as the
> language definition goes.

So what?

I can define integer and put that into a javascript variable,
you only define "integer type" differently from mine.

I can define date/time and put that into a javascript variable,
I even have internal javascript functions supporting that data type,
why should I be concerned about the internal representation?

I can define boolean true/false and put that into a javascript variable,
you only define "boolean type" differently from mine.

I can define a string as an decimal or hexadecimal or binary integer type, 
certainly that is a "number type",
and store that into a variable.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#26169

FromGene Wirchenko <genew@telus.net>
Date2014-11-19 13:43 -0800
Message-ID<6i3q6ap99050vgd1u3ecve4a8187sdqi5u@4ax.com>
In reply to#26166
On Wed, 19 Nov 2014 22:18:10 +0100, "Evertjan."
<exxjxw.hannivoort@inter.nl.net> wrote:

>Ben Bacarisse <ben.usenet@bsb.me.uk> wrote on 19 nov 2014 in 
>comp.lang.javascript:
>
>>>>      Since it is the only number type available for variables, 
>>>
>>> What about integers?
>> 
>> ECMAScript does not have a separate integer type.  You can represent any
>> integer in (2^53, 2^53) exactly (and zero twice!) using the built-in
>> Number type, but you are still using a floating point type as far as the
>> language definition goes.
>
>So what?
>
>I can define integer and put that into a javascript variable,
>you only define "integer type" differently from mine.

     The variable, if it holds a numeric value, is holding a
floating-point value.  Yes, some integers can fit in that, but the
variable type of Number is a floating-point type.

>I can define date/time and put that into a javascript variable,
>I even have internal javascript functions supporting that data type,
>why should I be concerned about the internal representation?

     Maybe, for your values, you do not need to.  Nonetheless, the
type exists.

>I can define boolean true/false and put that into a javascript variable,
>you only define "boolean type" differently from mine.
>
>I can define a string as an decimal or hexadecimal or binary integer type, 
>certainly that is a "number type",
>and store that into a variable.

     Yup, and all of those values are being stored as floating-point.

Sincerely,

Gene Wirchenko

[toc] | [prev] | [next] | [standalone]


#26172

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2014-11-19 22:40 +0000
Message-ID<87ppci3jct.fsf@bsb.me.uk>
In reply to#26166
"Evertjan." <exxjxw.hannivoort@inter.nl.net> writes:

> Ben Bacarisse <ben.usenet@bsb.me.uk> wrote on 19 nov 2014 in 
> comp.lang.javascript:
>
>>>>      Since it is the only number type available for variables, 
>>>
>>> What about integers?
>> 
>> ECMAScript does not have a separate integer type.  You can represent any
>> integer in (2^53, 2^53) exactly (and zero twice!) using the built-in
>> Number type, but you are still using a floating point type as far as the
>> language definition goes.
>
> So what?

Some people don't know that ECMAScript has only one Number type, and
your remark might have misled other into thinking otherwise, so I think
more explanation is helpful.  That's all.

> I can define integer and put that into a javascript variable,
> you only define "integer type" differently from mine.

Sure, but personal definitions of terms that have a technical meaning in
a particular language are often more confusing than helpful.  If you
like to think of Number variables that contain the floating point
representation of a whole number as having "integer type" that's fine,
but it's almost certainly going to be pointed out that you are not using
the standard meaning.

<snip>
-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#26174

FromTim Streater <timstreater@greenbee.net>
Date2014-11-19 22:51 +0000
Message-ID<191120142251329551%timstreater@greenbee.net>
In reply to#26172
In article <87ppci3jct.fsf@bsb.me.uk>, Ben Bacarisse
<ben.usenet@bsb.me.uk> wrote:

> "Evertjan." <exxjxw.hannivoort@inter.nl.net> writes:
> 
> > Ben Bacarisse <ben.usenet@bsb.me.uk> wrote on 19 nov 2014 in 
> > comp.lang.javascript:
> >
> >>>>      Since it is the only number type available for variables, 
> >>>
> >>> What about integers?
> >> 
> >> ECMAScript does not have a separate integer type.  You can represent any
> >> integer in (2^53, 2^53) exactly (and zero twice!) using the built-in
> >> Number type, but you are still using a floating point type as far as the
> >> language definition goes.
> >
> > So what?
> 
> Some people don't know that ECMAScript has only one Number type, and
> your remark might have misled other into thinking otherwise, so I think
> more explanation is helpful.  That's all.

There's nothing new about using floating point for integers anyway. The
CDC 6600 only had floating point hardware.

-- 
"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689

[toc] | [prev] | [next] | [standalone]


#26176

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2014-11-19 23:35 +0000
Message-ID<87egsy3gs3.fsf@bsb.me.uk>
In reply to#26174
Tim Streater <timstreater@greenbee.net> writes:

> In article <87ppci3jct.fsf@bsb.me.uk>, Ben Bacarisse
> <ben.usenet@bsb.me.uk> wrote:
<snip>
>> Some people don't know that ECMAScript has only one Number type, and
>> your remark might have misled other into thinking otherwise, so I think
>> more explanation is helpful.  That's all.
>
> There's nothing new about using floating point for integers anyway. The
> CDC 6600 only had floating point hardware.

Indeed.

But I think it's helpful to distinguish between a language and its
implementation.  For example, the CDC 6600 supported FORTRAN 66 with its
distinction between integer and real types.  The integer types where
implemented using floating point but they behaved as specified by the
language specification.  Likewise, an ECMAScript implementation is
permitted to use integer hardware in various ways, provided the results
conform with all the details of the language specification.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#26170

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2014-11-19 23:10 +0100
Message-ID<1460968.O2UKaiCUXN@PointedEars.de>
In reply to#26165
Ben Bacarisse wrote:

> ECMAScript does not have a separate integer type.  You can represent any
> integer in (2^53, 2^53) exactly (and zero twice!) using the built-in
          ^^^^^^^^^^^^^^^?
> Number type, but you are still using a floating point type as far as the
> language definition goes.

So far as Editions up to 5.1 are concerned, and if we are excluding the 
implemented ES4 draft.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#26171

FromTim Streater <timstreater@greenbee.net>
Date2014-11-19 22:32 +0000
Message-ID<191120142232431812%timstreater@greenbee.net>
In reply to#26165
In article <877fyr3sxr.fsf@bsb.me.uk>, Ben Bacarisse
<ben.usenet@bsb.me.uk> wrote:

> "Evertjan." <exxjxw.hannivoort@inter.nl.net> writes:
> 
> > Gene Wirchenko <genew@telus.net> wrote on 19 nov 2014 in 
> > comp.lang.javascript:
> >
> >> On Wed, 19 Nov 2014 17:52:40 +0100, "Christoph M. Becker"
> >> <cmbecker69@arcor.de> wrote:
> >> 
> >> [snip]
> >> 
> >>>ACK -- assuming that there are no implementation errors.  I rarely do
> >>>float calculations in ECMAScript implementations, so I don't know if
> >>>this assumption is reasonable.  Probably it is.
> >> 
> >>      Since it is the only number type available for variables, 
> >
> > What about integers?
> 
> ECMAScript does not have a separate integer type.  You can represent any
> integer in (2^53, 2^53) exactly (and zero twice!) using the built-in
> Number type, but you are still using a floating point type as far as the
> language definition goes.

Why twice? is the javascript VM a ones-complement machine?

-- 
"A committee is a cul-de-sac down which ideas are lured and then 
 quietly strangled." - Sir Barnett Cocks (1907-1989)

[toc] | [prev] | [next] | [standalone]


#26175

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2014-11-19 23:26 +0000
Message-ID<87k32q3h7i.fsf@bsb.me.uk>
In reply to#26171
Tim Streater <timstreater@greenbee.net> writes:

> In article <877fyr3sxr.fsf@bsb.me.uk>, Ben Bacarisse
> <ben.usenet@bsb.me.uk> wrote:
>
>> "Evertjan." <exxjxw.hannivoort@inter.nl.net> writes:
>>
>> > Gene Wirchenko <genew@telus.net> wrote on 19 nov 2014 in >
>> comp.lang.javascript:
>> >
>> >> On Wed, 19 Nov 2014 17:52:40 +0100, "Christoph M. Becker"
>> >> <cmbecker69@arcor.de> wrote:
>> >> >> [snip]
>> >> >>>ACK -- assuming that there are no implementation errors.  I
>> rarely do
>> >>>float calculations in ECMAScript implementations, so I don't know if
>> >>>this assumption is reasonable.  Probably it is.
>> >> >>      Since it is the only number type available for variables,
>> >
>> > What about integers?
>>
>> ECMAScript does not have a separate integer type.  You can represent any
>> integer in (2^53, 2^53) exactly (and zero twice!) using the built-in
>> Number type, but you are still using a floating point type as far as the
>> language definition goes.
>
> Why twice? is the javascript VM a ones-complement machine?

I'm talking about what the recent (5.1) language standard says.  The
Number type uses the IEEE 754 64-bit floating point format in which (to
quote) "there is both a positive zero and a negative zero" but you have
to work hard to find out which one you have!

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#26177

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2014-11-20 00:47 +0100
Message-ID<m4ja5p$hdd$1@solani.org>
In reply to#26175
Ben Bacarisse wrote:

> Tim Streater <timstreater@greenbee.net> writes:
> 
>> In article <877fyr3sxr.fsf@bsb.me.uk>, Ben Bacarisse
>> <ben.usenet@bsb.me.uk> wrote:
>>
>>> ECMAScript does not have a separate integer type.  You can represent any
>>> integer in (2^53, 2^53) exactly (and zero twice!) using the built-in
>>> Number type, but you are still using a floating point type as far as the
>>> language definition goes.
>>
>> Why twice? is the javascript VM a ones-complement machine?
> 
> I'm talking about what the recent (5.1) language standard says.  The
> Number type uses the IEEE 754 64-bit floating point format in which (to
> quote) "there is both a positive zero and a negative zero" but you have
> to work hard to find out which one you have!

To be precise, the IEEE 754 double-precision 64-bit *binary* format. :)

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#26178

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2014-11-20 00:17 +0000
Message-ID<878uj63ett.fsf@bsb.me.uk>
In reply to#26177
"Christoph M. Becker" <cmbecker69@arcor.de> writes:

> Ben Bacarisse wrote:
>
>> Tim Streater <timstreater@greenbee.net> writes:
>> 
>>> In article <877fyr3sxr.fsf@bsb.me.uk>, Ben Bacarisse
>>> <ben.usenet@bsb.me.uk> wrote:
>>>
>>>> ECMAScript does not have a separate integer type.  You can represent any
>>>> integer in (2^53, 2^53) exactly (and zero twice!) using the built-in
>>>> Number type, but you are still using a floating point type as far as the
>>>> language definition goes.
>>>
>>> Why twice? is the javascript VM a ones-complement machine?
>> 
>> I'm talking about what the recent (5.1) language standard says.  The
>> Number type uses the IEEE 754 64-bit floating point format in which (to
>> quote) "there is both a positive zero and a negative zero" but you have
>> to work hard to find out which one you have!
>
> To be precise, the IEEE 754 double-precision 64-bit *binary*
> format. :)

Very true.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#26179

FromDr J R Stockton <J.R.Stockton@physics.org>
Date2014-11-20 01:18 -0800
Message-ID<e73cadd0-6090-44f3-b4d3-62b7d811918b@googlegroups.com>
In reply to#26175
On Wednesday, November 19, 2014 11:26:33 PM UTC, Ben Bacarisse wrote:

> I'm talking about what the recent (5.1) language standard says.  The
> Number type uses the IEEE 754 64-bit floating point format in which (to
> quote) "there is both a positive zero and a negative zero" but you have
> to work hard to find out which one you have!

If the number X is known to be finite, it is only necessary to compare its reciprocal with [either] zero.  Otherwise, compare (X+1/X) with a zero.  It's not hard, if one is smart.  That has been discussed here in the past few years, and should be put in the newsgroup FAQ.


-- 
  (c) John Stockton, near London, UK.  Using Google, no spell-check.
 Mail: J.R.""""""""@physics.org or (better) via Home Page at
 Web:  <http://www.merlyn.demon.co.uk/> (may move soon)
 FAQish topics, acronyms, links, etc.; Date, Lagrange, JavaScript, ..|

[toc] | [prev] | [next] | [standalone]


#26180

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2014-11-20 13:47 +0000
Message-ID<87zjbmx9uc.fsf@bsb.me.uk>
In reply to#26179
Dr J R Stockton <J.R.Stockton@physics.org> writes:
<snip>
>  It's not hard, if one is smart.

Yes, "you have to work hard" was not a good phrase to use in a technical
group!  I meant that expressions that reveal the sign of the zero are
quite rare.

<snip>
-- 
Ben.

[toc] | [prev] | [next] | [standalone]


Page 3 of 5 — ← Prev page 1 2 [3] 4 5  Next page →

Back to top | Article view | comp.lang.javascript


csiph-web