I would expect the following two expressions to both evaluate to false: 2 < "12" "2" < "12" The second one returns false. That makes sense to me "1" is before "2". In the first case, we are comparing a number with a string. I would expect the number 1 to be converted to the string "1" and therefore to evaluate to false. However, it is evaluating to true. What am I missing? Thanks, Bob
BobInNJ
Posts
-
Comparison's in JavaScript -
Menu's in HTMLWhen developing (a relatively simple) web page, what is the best way to add a menu to it. I noticed that the HTML tag
has been depreciated. I also see that it has been brought back in HTML 5.0 so I am a bit confused. Please comment. Also could somebody point me to a good tutorial on menus in HTML? Thanks, Bob
-
Getting the Name of the BrowserI ran the following JavaScript code: alert( "browers is " + navigator.appName ); The browser I was using is Chrome. I expected to get the string Google Chrome but instead I got: Am I missing something? I am thinking that my security software is changing the name of the string to protect my system and/or my privacy. Is that right? Thanks, Bob
-
Java Code using the List Interface not CompilingPlease consider the following Java fragment where there are two classes defined: Tire and Radial. The class Radial has Tire has its super class. That is, Radial extends Tire.
public static void addBrandTires(List parts1, List parts2, String brand) { ListIterator li = parts1.listIterator(); while ( li.hasNext() ) { Radial t1 = li.next(); if ( t1.getBrand().equals( brand) ) { parts2.add( t1 ); } } }
The call to add generates the following compiler error: error: no suitable method found for add(Radial) parts2.add( t1 ); Since t1 is of type Radial, it is of type Tire therefore I expected it to work. I tired putting in a cast of t1 but that did not work either. Bob
-
Setting up a Login on a Web SiteRichard, Thanks for the response. We are planning on writing the server code in C++. From what I gather from your post, what you are telling me is that what I suggest will work. Do I have that right? Thanks Bob
-
Setting up a Login on a Web SiteI am currently working on a website with a friend and we want to support users logging in. Security is not a top a priority. We have HTML and JavaScript code which will extract the User's name and password. We want to use an object of XMLHttpRequest to call the server to verify the user. We would use a post. Does this approach make sense? If there is a better approach, I would like to know what it is. However, we do not want to use jQuery, ASP.Net or a relational database. I am now thinking that this should have been posted to the JavaScript forum. If so, I will post it there. Bob
-
Our WebSite and the IP AddressWhen the user goes to the site, the IP address of the site is shown in the address bar. We are using a static TCP/IP address on a Linux machine with a DNS entry. Bob
-
Our WebSite and the IP AddressMy friend and I have recently put up the website: www.chessratings.org . It is being hosted on my friends machine which runs Linux and uses Apache to host the site. When a user goes to the web address it works but in the address bar of the browser wwww.chessraings.org is gone and the URL of the site is shown. We do not understand why and we want to turn off this behavior. Bob
-
Having trouble with c++ templatesI have a c++ class that contains the following: template class Poly { public: Poly(int order = 0) { this->order = order; coeffs = new double[order+1]; for( int i = 0;i<=order; i++ ) coeffs[i] = 0; } Poly( int order, T *coeffs); Poly( Poly &poly ); ~Poly() { delete []coeffs; } // other member functions are not shown. friend ostream &operator << ( ostream &out, Poly &poly ); private: // data members not show. }; This class is defined in a file called poly.h. In the file poly.cpp, I have the following function definition: template ostream & operator << ( ostream &out, Poly &poly ) { bool printedCoeff = false; . . . return out; } In a third file called test.cpp, I have: double coeffs[] = { 3, 1, 2, 1 }; Poly p1(3,coeffs), p2; cout << p1 << endl; I am using the Microsoft Visual Studio and I get a linker error because of the statement: cout << p1 << endl; I believe that my definition of the function overloading << is not properly getting instantiated. How do I fix this? Bob
-
Putting up a Web SiteMy friend and I are currently working on putting up a website. We are doing this using HTML, CGI scripts written in C++ and the Apache Web Server. We are both highly experienced programmers, however, we are relatively new to web development. We want to require user's to login in. We are wondering how user login's are normal handled. Should we be using the login feature of Apache? Should we being doing this by using cookies. Maybe you could point me to a tutorial on the web related to this subject. Thanks Bob
-
Getting Quotes on Call Options and Put OptionsThanks for the response. I am writing C++ code and I am looking for a C++ callable library. Preferable an open source library. Also, before posting my question here, I did several searches using Google. However, they failed to turn up what I am looking for. Bob
-
Getting Quotes on Call Options and Put OptionsDoes anybody know of any third party libraries that I can use to get the prices of call options on stocks? I would like quotes on put prices also? Bob
-
Lining up the Decimal PointsDavid, Adding the line:
cout << setiosflags(ios::fixed);
before the for loop did the trick. The program now works as expected. I am happy. I thank you and all the other people who responded to my post for their help in this matter. Bob
-
Lining up the Decimal PointsI tried it with std::left, without std::left and with std::right. In all three cases it did not work. What I believe the problem is that there is no way to specified a fixed number of digits along with a fixed number of digits to the right of the decimal point. I think I am going to go use sprintf and then send the output the string sprintf produces. It is not the "C++ way" of doing things but it works. I want to thank the group for their responses. Bob
-
Lining up the Decimal PointsThanks for the response. However, it failed to produce the results I wanted. Here is part of the output that I got:
0 0 9.425 0 3.142 19.29 0 6.283 29.16 0 9.425 39.03 0 12.57 48.9 0 15.71 58.77
The decimal points are not lined up. What I want is:
0 0.0 9.425 0 3.142 19.29 0 6.283 29.16 0 9.425 39.03 0 12.57 48.9 0 15.71 58.77
In what I want the decimal points are all in the same column.
-
Lining up the Decimal PointsI would like to output three columns of numbers with the decimal points lined up. I wrote the following piece of code which I thought would do it.
for( int i = 0; i<100; i++ ) { double f1 = (int)(i/20); double f2 = 3.1415\*i; double f3 = 3.1415\*(f2+3); cout.width( 10 ); cout.precision( 4 ); cout << std::left << f1 << " "; cout.width( 10 ); cout << std::left << f2 << " "; cout.width( 10 ); cout << std::left << f3 << endl; }
However, the decimal points are not lined up. Also, I want to do this in C++ not C. That is, I do not want to use, printf, fprintf or sprintf. How do I get the decimal points to line up vertical? Thanks Bob
-
Deleting FilesThanks for the responses. Based upon the responses I received I was able to write the code I wanted. Bob
-
Deleting FilesI am working on a Windows program in C++ that downloads a variable number of files into a directory. Before I do the download, I want to delete all the files in the directory before downloading them. I do not want to write a separate script to do this. I want the C++ program to do it. What is the easiest way to do this? Bob
-
GMP and WindowsI would like to use a "Big Number" package for my application which I am writing on Windows using Visual Studio and C++. Therefore, I thought I would use GMP. However, I get the impression that compiling it under Windows is going to be a big job. Therefore, I am wondering if it is worth doing. Could somebody suggest a different package that is more geared towards the windows environment? Thanks Bob
-
Day of the WeekGiven a month and year, I want to write C++ code to determine what day of the week the month starts at. For example, for 2/2013, I want the code to return Friday (or an integer representing Friday) because February 1, 2013 was a Friday. The code needs to be portable. What is the best way to do this? Thanks Bob