I've this comparison with two numbers
if (t.minimum.value t.maximum.value) ...
yet it's always true except when minimum and maximum are identical. Why
isn't it false when minimum is smaller than maximum?
O. Wyss
--
Cross-platform applications: http://wyoguide.sf.net/index.php?page=projectlist.php 13 1448
On Feb 14, 6:59 pm, Otto Wyss <otw...@bluewin.chwrote:
I've this comparison with two numbers
if (t.minimum.value t.maximum.value) ...
yet it's always true except when minimum and maximum are identical.
Why isn't it false when minimum is smaller than maximum?
The odds are that your 'numbers' are actually strings and your
comparison is lexical.
Richard.
Otto Wyss wrote:
I've this comparison with two numbers
if (t.minimum.value t.maximum.value) ...
yet it's always true except when minimum and maximum are identical. Why
isn't it false when minimum is smaller than maximum?
Try
if (+t.minimum.value +t.maximum.value)
If there is a chance the values are strings and not numbers.
--
Ian Collins.
Ian Collins wrote:
Otto Wyss wrote:
>I've this comparison with two numbers
if (t.minimum.value t.maximum.value) ...
yet it's always true except when minimum and maximum are identical. Why isn't it false when minimum is smaller than maximum?
Try
if (+t.minimum.value +t.maximum.value)
I can't believe it, yet it works!
If there is a chance the values are strings and not numbers.
I'm probably going to dislike Javascript if I have to use it more.
O. Wyss
--
Cross-platform applications: http://wyoguide.sf.net/index.php?page=projectlist.php
On Feb 15, 12:20 am, Otto Wyss <otw...@bluewin.chwrote:
I'm probably going to dislike Javascript if I have to use it more.
So what will you program your pages then? On C#? :-)
If the solution by Ian Collins is too "babish" for you then you may
use "light Java" way:
if (new Number(t.minimum.value).valueOf() new
Number(t.maximum.value).valueOf()) {
}
For full satisfaction you may try "hardcore Java" way as well:
function trutherize(n1, n2) {
return new Boolean(n1.valueOf() n2.valueOf());
}
function Numerizer(v) {
return new Number(v);
}
if ( trutherize(new Numerizer(t.minimum.value), new
Numerizer(t.maximum.value)).valueOf() ) {
}
:-)
Otto Wyss wrote:
I'm probably going to dislike Javascript if I have to use it more.
If you insist on programming in ignorance I would expect you to dislike it a
lot. Programming is a profession that requires deep and specific knowledge. It
can't be done well if you don't know what you are doing.
This may help: http://javascript.crockford.com/survey.html
Douglas Crockford scribed:
>Otto Wyss wrote:
>I'm probably going to dislike Javascript if I have to use it more.
If you insist on programming in ignorance I would expect you to dislike it a lot. Programming is a profession that requires deep and specific knowledge. It can't be done well if you don't know what you are doing.
This may help: http://javascript.crockford.com/survey.html
Within this site it states, "JavaScript shares C-family syntax with Java.."
I know a bit of javascript, but to my prior knowledge I know nothing of C.
Are they syntactically identical?
--
Ed Jay (remove 'M' to respond by email)
On Feb 15, 8:04 am, "VK" <schools_r...@yahoo.comwrote:
On Feb 15, 12:20 am, Otto Wyss <otw...@bluewin.chwrote:
I'm probably going to dislike Javascript if I have to use it more.
So what will you program your pages then? On C#? :-)
If the solution by Ian Collins is too "babish" for you then you may
use "light Java" way:
if (new Number(t.minimum.value).valueOf() new
Number(t.maximum.value).valueOf()) {
}
It might have been better to suggest:
if (Number(t.minimum.value) Number(t.maximum.value)) {
Given that some consider it to be less confusing and more maintainable
than using unary + for type conversion.
>
For full satisfaction you may try "hardcore Java" way as well:
function trutherize(n1, n2) {
return new Boolean(n1.valueOf() n2.valueOf());
}
Which is completely unnecessary: where the evaluation uses < or a
boolean is always returned:
alert( typeof (5 6) ); // shows boolean
Similarly for some other comparison operators, but not && or ||
('guard' and 'default' in Crocksford-speak) which return the value of
one of the operand expressions, which *might* be boolean. :-)
--
Rob
Ed Jay wrote:
Douglas Crockford scribed:
>>Otto Wyss wrote:
>>>I'm probably going to dislike Javascript if I have to use it more.
If you insist on programming in ignorance I would expect you to dislike it a lot. Programming is a profession that requires deep and specific knowledge. It can't be done well if you don't know what you are doing.
This may help: http://javascript.crockford.com/survey.html
Within this site it states, "JavaScript shares C-family syntax with Java.."
I know a bit of javascript, but to my prior knowledge I know nothing of C.
Are they syntactically identical?
No, but they are similar.
--
Ian Collins.
Ian Collins scribed:
>Ed Jay wrote:
>Douglas Crockford scribed:
>>>Otto Wyss wrote:
I'm probably going to dislike Javascript if I have to use it more.
If you insist on programming in ignorance I would expect you to dislike it a lot. Programming is a profession that requires deep and specific knowledge. It can't be done well if you don't know what you are doing.
This may help: http://javascript.crockford.com/survey.html
Within this site it states, "JavaScript shares C-family syntax with Java.."
I know a bit of javascript, but to my prior knowledge I know nothing of C. Are they syntactically identical?
No, but they are similar.
Thanks.
--
Ed Jay (remove 'M' to respond by email)
RobG wrote:
It might have been better to suggest:
if (Number(t.minimum.value) Number(t.maximum.value)) {
Given that some consider it to be less confusing and more maintainable
than using unary + for type conversion.
Yes, that's IMO much better since it's obvious what's meant. Thanks.
O. Wyss
--
Cross-platform applications: http://wyoguide.sf.net/index.php?page=projectlist.php
In comp.lang.javascript message <11*********************@p10g2000cwp.goo
glegroups.com>, Wed, 14 Feb 2007 18:43:33, RobG <rg***@iinet.net.au>
posted:
> It might have been better to suggest:
if (Number(t.minimum.value) Number(t.maximum.value)) {
Given that some consider it to be less confusing and more maintainable than using unary + for type conversion.
Number is, however, several times slower than + in IE6 - maybe because
it *requires* the creation of two Objects. If the OP is just checking
input control fields, that will not matter; if the code is used in a
large Sort, it might.
Strangely, it seems that this use of unary + was not obvious /a priori/;
but, /a posteriori/, when one reads it in working code, what else could
it be for?
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Dr J R Stockton wrote on 21 feb 2007 in comp.lang.javascript :
In comp.lang.javascript message <11*********************@p10g2000cwp.goo
glegroups.com>, Wed, 14 Feb 2007 18:43:33, RobG <rg***@iinet.net.au>
posted:
>> It might have been better to suggest:
if (Number(t.minimum.value) Number(t.maximum.value)) {
Given that some consider it to be less confusing and more maintainable than using unary + for type conversion.
Number is, however, several times slower than + in IE6 - maybe because
it *requires* the creation of two Objects. If the OP is just checking
input control fields, that will not matter; if the code is used in a
large Sort, it might.
Strangely, it seems that this use of unary + was not obvious /a priori/;
but, /a posteriori/, when one reads it in working code, what else could
it be for?
I strongly agree.
The unary + has no other practical function, or do I miss something?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
In comp.lang.javascript message <Xn********************@194.109.133.242>
, Wed, 21 Feb 2007 08:08:32, Evertjan. <ex**************@interxnl.net>
posted:
> The unary + has no other practical function, or do I miss something?
It may not have any other function within hand-composed source.
Well, that's not quite true - as well as converting a numeric String to
Number, it will also convert a Boolean. In fact, I used it on Monday,
in adding to js-anclk.htm, like (of course, there's at least one other
reasonable way to code that selection) :
var OO = ["OFF", "ON"]
OK = T>=5 && T<15 // adapt
dg.innerText = OO[+OK]
Then one should be able to enter both +3*3 and -3*3 in a control
accepting expressions, to be read by such as
function UserIn(Ctrl) { return +eval(Ctrl.value) /* for exprns */ }
The unary + in the function removes all possible doubt about the result
being a Number, as before; but one wants unary + to be allowable in the
argument of eval().
Use of eval for JSON input probably needs unary +.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: bettervssremoting |
last post by:
To view the full article, please visit
http://www.BetterVssRemoting.com
Better VSS Remote Access Tool
This article makes a detailed comparison among SourceAnyWhere,
SourceOffSite, VSS...
|
by: Jason |
last post by:
Hi, below is example code which demonstrates a problem I have encountered.
When passing a number to a function I compare it with a string's size and
then take certain actions, unfortunately during...
|
by: Dave |
last post by:
Hello all,
I would like to solicit suggestions on how to most efficiently accomplish
something. I have profiled the project I'm working on and have found that
calls to fabs() are taking a very...
|
by: mayamorning123 |
last post by:
A comparison among six VSS remote tools including SourceOffSite ,
SourceAnyWhere, VSS Connect, SourceXT, VSS Remoting, VSS.NET
To view the full article, please visit...
|
by: bettervssremoting |
last post by:
To view the full article, please visit
http://www.BetterVssRemoting.com
Better VSS Remote Access Tool
This article makes a detailed comparison among SourceAnyWhere,
SourceOffSite, VSS...
|
by: spam.noam |
last post by:
Hello,
Guido has decided, in python-dev, that in Py3K the id-based order
comparisons will be dropped. This means that, for example, "{} < "
will raise a TypeError instead of the current...
|
by: ma740988 |
last post by:
template <class T> inline bool isEqual( const T& a, const T& b,
const T epsilon = std::numeric_limits<T>::epsilon() )
{
const T diff = a - b;
return ( diff <= epsilon ) && ( diff >= -epsilon );...
|
by: Stevie |
last post by:
Hello
I'm trying to work out the regular expression for carrying out a simple
'greater than' comparison.
I have a directory with files such as asd345.log, asd346.log,
asd347.log and so on.
|
by: MLH |
last post by:
After entering a date (earlier than today's date) into a textbox
control though, I'm stumped as to why VBA thinks date I enter into the
control is greater than Now - when they are CLEARLY less than...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |