Integer Concatination

Combining numbers

  • (2 Pages)
  • +
  • 1
  • 2

26 Replies - 5417 Views - Last Post: 09 May 2005 - 08:47 AM Rate Topic: -----

#1 neo1piv14  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 26-April 05

Integer Concatination

Posted 06 May 2005 - 11:30 AM

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
Is This A Good Question/Topic? 0
  • +

Replies To: Integer Concatination

#2 WolfCoder  Icon User is offline

  • Isn't a volcano just an angry hill?
  • member icon


Reputation: 790
  • View blog
  • Posts: 7,623
  • Joined: 05-May 05

Re: Integer Concatination

Post icon  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.
Was This Post Helpful? 0
  • +
  • -

#3 zakary  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 27
  • View blog
  • Posts: 427
  • Joined: 15-February 05

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
Was This Post Helpful? 0
  • +
  • -

#4 neo1piv14  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 26-April 05

Re: Integer Concatination

Posted 06 May 2005 - 11:34 AM

Thank you very much oh great and wise Foo Coder.
Was This Post Helpful? 0
  • +
  • -

#5 neo1piv14  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 26-April 05

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
Was This Post Helpful? 0
  • +
  • -

#6 WolfCoder  Icon User is offline

  • Isn't a volcano just an angry hill?
  • member icon


Reputation: 790
  • View blog
  • Posts: 7,623
  • Joined: 05-May 05

Re: Integer Concatination

Post icon  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.
Was This Post Helpful? 0
  • +
  • -

#7 malkiri  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 3
  • View blog
  • Posts: 364
  • Joined: 29-March 01

Re: Integer Concatination

Posted 06 May 2005 - 11:37 AM

Why don't you just input it as an integer to begin with?
Was This Post Helpful? 0
  • +
  • -

#8 WolfCoder  Icon User is offline

  • Isn't a volcano just an angry hill?
  • member icon


Reputation: 790
  • View blog
  • Posts: 7,623
  • Joined: 05-May 05

Re: Integer Concatination

Post icon  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.
Was This Post Helpful? 0
  • +
  • -

#9 neo1piv14  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 26-April 05

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.
Was This Post Helpful? 0
  • +
  • -

#10 BlackJesus  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 161
  • Joined: 10-February 05

Re: Integer Concatination

Posted 06 May 2005 - 11:40 AM

can u pull the numbers out of a string using Integer.parseInt(); ?
Was This Post Helpful? 1

#11 malkiri  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 3
  • View blog
  • Posts: 364
  • Joined: 29-March 01

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.

This post has been edited by malkiri: 06 May 2005 - 11:42 AM

Was This Post Helpful? 0
  • +
  • -

#12 WolfCoder  Icon User is offline

  • Isn't a volcano just an angry hill?
  • member icon


Reputation: 790
  • View blog
  • Posts: 7,623
  • Joined: 05-May 05

Re: Integer Concatination

Post icon  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.
Was This Post Helpful? 0
  • +
  • -

#13 neo1piv14  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 26-April 05

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();
Was This Post Helpful? 0
  • +
  • -

#14 WolfCoder  Icon User is offline

  • Isn't a volcano just an angry hill?
  • member icon


Reputation: 790
  • View blog
  • Posts: 7,623
  • Joined: 05-May 05

Re: Integer Concatination

Post icon  Posted 06 May 2005 - 11:45 AM

Well. You couldn't understand JAVA so he tried something different to see if you understood that.
Was This Post Helpful? 0
  • +
  • -

#15 <aFk-Al>  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 05-May 05

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.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2