Search 5,000,000+ questions and answers.

Frequently Asked Questions

Why does 1+1 equal 11? or How do I convert a string to a number?

comp.lang.javascript FAQ - 9.91 - 2008-01-19
Javascript variables are loosely typed: the conversion between a string and a number happens automatically. Since plus (+) is also used as in string concatenation, '1' + 1 is equal to '11' : the String deciding what + does. To overcome this, first convert the string to a number. For example: +varname or Number(varname) or parseInt(varname, 10) or parseFloat(varname) . Prompt and form control values are strings, as is the result from a prompt window.
Related Questions

How do I convert a string to a number?

Updating the For Beginners forum FAQ - GameDev.Net Discussio...
I am including the header file <string>, and I am using the string class, but the code doesn't compile? (namespace resolution, having the std:: topics) How do I use unique() with vectors? (answered only once, but still a good question to have due to people not knowing that it's possible to do)
Related Questions

How do I convert a std::string to a number?

Miscellaneous technical issues, C++ FAQ Lite
There are two easy ways to do this: you can use the <cstdio> facilities or the <iostream> library. In general, you should prefer the <iostream> library.
Related Questions

How to convert a string to a number using JavaScript?

AKAAS :: JavaScript Interview Questions and Answers | JavaSc...
You can use the parseInt() and parseFloat() methods. Notice that extra letters following a valid number are ignored, which is kinda wierd but convenient at times.
Related Questions

To help us stop spam signups, could you kindly answer this simple question: what does 1 + 1 equal?

Frequently asked off-plan and new-build property and portfol...
It's not so much working with an impersonal company as buying property with friends who know how to do this. You learn a lot in the process.You don't get left to deal with it all and can get as little or as much help as you need. We can now look forward to completing on our second property knowing that we have a great team at YPC looking after us
Related Questions

How do I convert a value (a number, for example) to a std::string?

Miscellaneous technical issues, C++ FAQ Lite
There are two easy ways to do this: you can use the <cstdio> facilities or the <iostream> library. In general, you should prefer the <iostream> library. The <iostream> library allows you to convert pretty much anything to a std::string using the following syntax (the example converts a double, but you could substitute pretty much anything that prints using the << operator): The std::ostringstream object o offers formatting facilities just like those for std::cout.
Related Questions

Why does it send back the same string twice?

Expect FAQ (Frequently Asked Questions)
From: Don Libes To: yusufg@himalaya.cc.gatech.edu (Yusuf Goolamabbas) Subject: Duplicate pattern matches in Expectk --text follows this line-- Hi, I am trying to do a very simple thing in expectk spawn cat expect_background -re ".+" { send $expect_out(0,string) } exp_send "Hello World\n" Now the display in the text widget looks like this Hello World\r Hello World\r whereas I was expecting only one line Hello World\r Thanks in advance, Yusuf -- Yusuf Goolamabbas yusufg@cc.gatech.
Related Questions

Why does the number of pages examined never equal the initial number 'Left to do'?

MIDI Harvester - FAQs
Some links to certain pages may be dead (give a 404 - page not found error). These pages obviously cannot be examined. If the page takes an unreasonable amount of time to retrieve, it may also be abandoned.
Related Questions

How many expansion cabinets can be added to an Option 11 Meridian 1 system?

Black Box Resale Services: Frequently Asked Questions
For an Option 11 (NTAK01 CPU card) you can add 1 expansion cabinet. For an Option 11E (NTBK45 CPU card) you can add 2 fiber expansion cabinets, for an Option 11C (NTDK20 CPU card) you can add 2 fiber expansion cabinets, but if you are running release 24 or higher software, you can add 4 fiber expansion cabinets.
Related Questions

How do I convert a real number (e.g. 1.0) to an integer (1) format?

ECLiPSe Programming FAQ
Often you'll want to round the real number appropriately first (round/2, floor/2, ceiling/2) rather than relying on fix's truncation. See the documentation for is/2 and fix/2.
Related Questions

How to convert the datetime into a string for use in the SQL ' statement?

Megasolutions.net :: Asp.Net Frequently Asked Questions - FA...
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Private Sub ddlCulture_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlCulture.SelectedIndexChanged
Related Questions

How do I convert an integer to a string representation?

CSC 209 Summer 2006
Well, printf does it for output, so look at its related function named sprintf that "prints formated output to a string."
Related Questions

How can I convert an integer or a float to a string?

Frequently Asked Questions
It's easy. Use sprintf. For example: char string1[50]; char string2[50]; short int var1; float var2; ... sprintf (string1, "%d", var1); sprintf (string2, "%f", var2);
Related Questions

How can I convert from string to int ?

C++ corner
You want to make a function that converts from a type to another. Like from std::string to int, or the other way around. This can be done using std::stringstream and insertion / extraction operators. Just as above, templates will prove of great help: Its usage is not as straightforward as the above explained max template. Normally, you would want to call it like "int value = lexical_cast( myStdString );". There is, however, a problem.
Related Questions

How do I convert a string into an internet address?

Programming UNIX Sockets in C - Frequently Asked Questions: ...
If you are reading a host's address from the command line, you may not know if you have an aaa.bbb.ccc.ddd style address, or a host.domain.com style address. What I do with these, is first try to use it as a aaa.bbb.ccc.ddd type address, and if that fails, then do a name lookup on it. Here is an example: Converts ascii text to in_addr struct. NULL is returned if the address can not be found.
Related Questions

How do I convert from int to string?

FAQ - CPP
Converting from int to string is a little more complicated than converting a string to int. There are no standard C++ functions for this, but there is a way to do it using standard stringstreams. The class stringstream is declared in header sstream and is used like this: std::stringstream ss; std::string str; ss << 31337; ss >> str;
Related Questions

Question 1: How do I get a case number?

HUD FAQ - FHA
Answer: Case numbers are requested through the FHA Connection. Access FHA Connection, go to Single Family Origination, go to Case Processing and then go to Case Number Assignment. You may also use an alternative service provider, such as ECHO Connection Plus as long as their capabilities are the same as the FHA Connection.
Related Questions

How many apples equal 1 serving?

Mott's Fresh Apples - FAQs>apple info
For people trying to reach their goal of eating 5 or more servings of fruits or vegetables a day 1 medium sized apple = 1 serving.
Related Questions

Is the number of grafts equal to the number of hairs transplanted?

Welcome to The Griffin Center > Frequently Asked Question...
No. Each follicular unit graft contains 1 to 4 hairs. This means if a patient has a 2,000 grafts implanted in one session, he may potentially have upwards of 6,000+ hairs transplanted.
Related Questions

How do you convert degrees, minutes, and seconds to and from a decimal number?

DCP: Frequently Asked Questions
Example: To convert 49 degrees 30 minutes and 45 seconds to decimal degrees: dn = 49 + 30/60 + 45/3600 = 49.5125 Note that int(n) denotes taking the integer part of a number (e.g. int(49.5125) = 49) and frac its fractional part (e.g. frac(49.5125) = 0.5125). mi is an intermediate result. Example: To convert 49.5125 decimal degrees to degrees, minutes and seconds: d = int(49.5125) = 49 mi= frac(49.5125)*60 = 0.5125*60 = 30.75 m = int(mi) = int(30.75) = 30 s = frac(mi)*60 = 0.
Related Questions

How do I convert a string to an int etc?

FAQ for the microsoft.public.languages.csharp newsgroup
In general, when you want to convert from one type to another, the first class to look at is System.Convert. It has a load of static methods which are likely to help you. If you're converting from a String, you could also check whether the type that you want to convert to has a Parse method or something similar - for instance, I usually use DateTime.ParseExact to convert from a String to a DateTime.
Related Questions

Q. How do I convert from string to int?

C++ FAQs - General
The simplest way is to use the function int std::atoi(const char*) declared in cstdlib. For example, std::atoi("31337") returns 31337. Alternatively, you can use std::strtol() or std::strtoul(). These functions provide more functionality such as the ability to convert hexadecimal or octal number strings, and are also declared in cstdlib.
Related Questions

Q. How do I convert from int to string?

C++ FAQs - General
Converting from int to string is a little more complicated than converting a string to int. There are no standard C++ functions for this, but there is a way to do it using standard stringstreams. The class stringstream is declared in header sstream and is used like this:
Related Questions

How do I convert a string to all upper or lower case?

Library Functions
Some libraries have routines strupr and strlwr or strupper and strlower, but these are not Standard or portable. It's a straightforward exercise to write upper/lower-case functions in terms of the toupper and tolower macros in <ctype.h>; see also question 13.5. (The only tricky part is that the function will either have to modify the string in-place or deal with the problem of returning a new string; see question 7.5a.
Related Questions

Got A Question? Ask Our Community!


More Questions >>

© Copyright 2007-2008 QueryCAT
About • Webmasters • Contact