• Post Reply Bookmark Topic Watch Topic
  • New Topic

Semantic error in Hexadecimal converter  RSS feed

 
Eric Mitchell
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sure the solution is simple, but I can NOT find it. Can anyone help me with this?



thank you
 
Anindya Roy
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where is TextIO.getln() ?
 
Anindya Roy
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What error you are getting ? I have run it. It's working fine.
 
Eric Mitchell
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, it is supposed to give the base-10 value of a hexadecimal, but the numbers do not come out right. For instance, if I put in "1" it comes out with 49. "0" comes out as 48. Letters come out correctly, but only when there is only one character of input.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric Mitchell wrote:well, it is supposed to give the base-10 value of a hexadecimal, but the numbers do not come out right. For instance, if I put in "1" it comes out with 49. "0" comes out as 48. Letters come out correctly, but only when there is only one character of input.

I suggest you look at a table of ASCII characters, because that will probably give you a big clue as to what's happening.
Unfortunately, char is a numeric type; but it doesn't work the same as an int.

HIH

Winston

PS: Your code lines are far too long, and it makes your thread very difficult to read.
I'd break them up myself, but you have tons of them, so I suggest you edit the post yourself. You can use the Edit icon at the top right of the post.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Another problem I can see is the non‑private field. All fields except those used as global constants should have private access, and I think that variable probably actually belongs inside the method.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!