Unfortunately >> works on bits rather than integers, so I do not think that
situation would work.
You could use the mod operator '%'
int remainder= 0;
int divisor = 10;
while(intNum > 0) {
remainder = intNum % divisor;
System.out.println("Number is : " & remainder);
intNum /= divisor;
}
HTH,
Fintan
> -----Original Message-----
> From: Jeff Fisher [SMTP:[EMAIL PROTECTED]]
> Sent: 04 September 2002 12:59
> To: JDJList
> Subject: [jdjlist] Getting digits from an integer
>
> I need to be able to get each individual digit from an integer as an
> integer. I think I should be able to do this by using the >> operator,
> but
> I just can't seem to figure it out.
>
> For example if I have a number 123, I need to get 3, then the 2, then the
> 1.
> It doesn't really matter the order, I just need the digits. I suppose I
> could convert it to a string and go that route, but that seems like a
> waste.
>
> Does anyone have experience with this or can point me to some
> examples/information.
>
> Thanks
>
> Jeff
>
> To change your JDJList options, please visit:
> http://www.sys-con.com/java/list.cfm
* ** *** ** * ** *** ** * ** *** ** *
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed.
Any views or opinions presented are solely those of the author, and do not necessarily
represent those of ESB.
If you have received this email in error please notify the sender.
Although ESB scans e-mail and attachments for viruses, it does not guarantee
that either are virus-free and accepts no liability for any damage sustained
as a result of viruses.
* ** *** ** * ** *** ** * ** *** ** *
To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm