RE: Hi Rick

  • From: "Joseph Lee" <joseph.lee22590@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Mon, 23 Nov 2009 01:07:29 -0800

Hi,

First, what kind of number are you using? Using different data tuype has
different consequences. If you are declaring "281" as an integer, then we
could use division function and store the integer part as a separate
variable. If you are using a double or a float data type, then we need to do
more than division - up to modulus function (getting the remainder of a
division). Also, are you going to sort the remaining numbers or just the
first digit?

If the numbers were declared as a string, you can use the position and
substring function to figure out the position and store the first digit
(position 0) as a separate variable. Since you didn't specify which one -
string or numbers, I'll assume that you are using numbers.

Given that you are using only numeric data types, here are theoretical
algorithms:

In the case of only retrieving the first digit: Divide the data by 100 and
override the previous record with the new data. Note that if you use double
or float, the decimal remainders will get on your way, so you need to do
something to get rid of it.

If continuing with the next digits: Divide the number by 100, then use
modulus function and a second variable to retrieve and store the remainder.

Hope this helps.

Cheers,

Joseph 

 

From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Celia Rodriguez
Sent: Monday, November 23, 2009 12:08 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: Hi Rick

 

In C# is there a way to reference a single digit out of a x number?

 

For example:

IfI have a number 281, and I only want to reference the number 2, how can I
do this 

 

Thank you for any help.

celia

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.425 / Virus Database: 270.14.77/2520 - Release Date: 11/22/09
19:40:00

  • References:

Other related posts: