HOW DO I CONVERT A NUMBER'S MOST SIGNIFICANT DIGIT TO A SINGLE DI.

M

maxq777

I am trying to work a problem for a random number generator. Essentially,
the random number is being generated by using two random number generators (X
= 1 to 100 and Y = 1 to 100) and then dividing X by Y to get a seed for the
random nujber.

I need to take the most significant digit of the number and convert it to an
integer between 1 and 9.

Any idea as to how I can do this?
 
R

Ron Rosenfeld

I am trying to work a problem for a random number generator. Essentially,
the random number is being generated by using two random number generators (X
= 1 to 100 and Y = 1 to 100) and then dividing X by Y to get a seed for the
random nujber.

I need to take the most significant digit of the number and convert it to an
integer between 1 and 9.

Any idea as to how I can do this?


I believe:

=--MID(A1,MIN(SEARCH({1,2,3,4,5,6,7,8,9},A1&"123456789")),1)

will return the most significant digit as an integer.
--ron
 
R

Rick Rothstein \(MVP - VB\)

Just out of curiosity, in which random number function are you using this
"seed" value?

Rick
 
B

Bernd P

Hello,

Another solution might be
=--LEFT(TEXT(ABS(A1),"0.000000000000000E+0"),1)

Regards,
Bernd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top