We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,612 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

A three-digit input converted to integer

Here's the problem, I was wondering if i am right to assume that when a three-digit input is entered, i.e. 123, then the string 1 will be stored to al, 2 to ah, but i'm not sure where the 3 goes, or if ever it's plain wrong to look at the problem that way. Here's my plan, ask for 3-digit number, access the digits separately, convert to integer, manipulate the digits separately, then check if greater than 100, 175, and so so.

3
Contributors
5
Replies
5 Hours
Discussion Span
9 Months Ago
Last Updated
6
Views
AlitaMixx
Newbie Poster
3 posts since Jul 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

In my opinion you need to use 3 different variables and store each digit in a separate variable, next convert each digit to an integer, multiply the first digit by 100, the second digit by 10 and add all digits together and save to a variable to get a 3 digit number.

With this you only need to compare one variable for the rest of the operations

zeroliken
Nearly a Posting Virtuoso
1,346 posts since Nov 2011
Reputation Points: 214
Solved Threads: 205
Skill Endorsements: 13

I see, so it's impossible then to convert a single 3-digit input to integer? Thanks.

AlitaMixx
Newbie Poster
3 posts since Jul 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

I see, so it's impossible then to convert a single 3-digit input to integer?

you can convert at any length if it's in a single variable, I've been taught that using nasm when you input a 3 or more digit number in a terminal you need to store the digits in separate variables for better manipulation in the program

zeroliken
Nearly a Posting Virtuoso
1,346 posts since Nov 2011
Reputation Points: 214
Solved Threads: 205
Skill Endorsements: 13

That was really helpful. Thank you.

AlitaMixx
Newbie Poster
3 posts since Jul 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

You don't need many buffers. You have one buffer for your input right? That is all you need. Write a conversion function (or find one on the net, but you will better yourself writing it on your own) that takes a pointer to your input buffer, and goes thourgh each character in your buffer, converts them all and returns the integer in eax.

GunnerInc
xor eax, eax
Team Colleague
90 posts since Jan 2011
Reputation Points: 38
Solved Threads: 13
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0662 seconds using 2.67MB