I'm trying to combine two integers. Example, when I read a character at a location and tell it to check the next character. So if i input 10, it reads the 1 and then the 0. How do i get it to combine those two integers into 10? Thanks
Integer ConcatinationCombining numbers
26 Replies - 5158 Views - Last Post: 09 May 2005 - 08:47 AM
Replies To: Integer Concatination
#2
Re: Integer Concatination
Posted 06 May 2005 - 11:32 AM
Since it is a two digit number, subtract 48 to the two chars.
Next, multiply the first digit by 10 then add the next.
You get 10 in your case.
Next, multiply the first digit by 10 then add the next.
You get 10 in your case.
#3
Re: Integer Concatination
Posted 06 May 2005 - 11:33 AM
do you what it value to stay an Integer or to change to a String
#4
Re: Integer Concatination
Posted 06 May 2005 - 11:34 AM
Thank you very much oh great and wise Foo Coder.
#5
Re: Integer Concatination
Posted 06 May 2005 - 11:34 AM
Zackary, I want to keep it as an integer because im doing math with it
#6
Re: Integer Concatination
Posted 06 May 2005 - 11:36 AM
You MUST check to see if the number is one digit, two digits, or three digits! For example, three characters hold the number.
If you multiplied the first by ten when there was only one character then you get an incorrect answer.
Or when it is a three digit number you get more weird answers.
Don't forget to check it out dogg.
If you multiplied the first by ten when there was only one character then you get an incorrect answer.
Or when it is a three digit number you get more weird answers.
Don't forget to check it out dogg.
#7
Re: Integer Concatination
Posted 06 May 2005 - 11:37 AM
Why don't you just input it as an integer to begin with?
#8
Re: Integer Concatination
Posted 06 May 2005 - 11:38 AM
Then you get the strangest infinite loop thing ever.
It's an equation held in a string. There are no spaces to the program can't tell the difference! PARSING is the keyword.
It's an equation held in a string. There are no spaces to the program can't tell the difference! PARSING is the keyword.
#9
Re: Integer Concatination
Posted 06 May 2005 - 11:40 AM
I AM inputting it as an integer. Problem is, i have to check it character by character because there are also + and - signs in the inputted text. That's why I'm checking character by character.
#10
Re: Integer Concatination
Posted 06 May 2005 - 11:40 AM
can u pull the numbers out of a string using Integer.parseInt(); ?
#11
Re: Integer Concatination
Posted 06 May 2005 - 11:40 AM
Is it an equation? He doesn't say so in his post.
Edit: I see.
Edit: I see.
This post has been edited by malkiri: 06 May 2005 - 11:42 AM
#12
Re: Integer Concatination
Posted 06 May 2005 - 11:41 AM
I wrote my own parsing code to do that. Integers and mess are the wrong way to go for me.
If there was a simple way out, I didn't use it because I usually write my own everything.
If there was a simple way out, I didn't use it because I usually write my own everything.
#13
Re: Integer Concatination
Posted 06 May 2005 - 11:44 AM
I've never heard of parseInt()
I guess that slipped our teacher's mind or something. The code he gave us is pretty screwy. Get this, im in a java class, he gives us an example.....IN PASCAL PSUEDO CODE! I dont know about any other java programmers out there, but i just dont understand pascal. Probably because i never learned it. Sorry for the tangent. But ya, i might try that parseInt();
I guess that slipped our teacher's mind or something. The code he gave us is pretty screwy. Get this, im in a java class, he gives us an example.....IN PASCAL PSUEDO CODE! I dont know about any other java programmers out there, but i just dont understand pascal. Probably because i never learned it. Sorry for the tangent. But ya, i might try that parseInt();
#14
Re: Integer Concatination
Posted 06 May 2005 - 11:45 AM
Well. You couldn't understand JAVA so he tried something different to see if you understood that.
#15
Re: Integer Concatination
Posted 06 May 2005 - 11:48 AM
Maybe if he tought us the JAVA we would understand it. But you're right, if we cant get the program we're in class to learn, we'll understand some other random language for sure.
|
|

New Topic/Question
Reply




MultiQuote







|