Shifting only works for powers of two. In any case, it is a substitute for what is actually happening: you are dividing by the radix.

So, to get the tens place from a decimal number, you must first divide by ten, then get the remainder of another division by ten. For example:

4321
4321 divide 10 --> 432
432 modulo 10 --> 2

To get the hundreds place, you divide by ten twice (which is the same as dividing by 100). Etc.

Typical integer to string conversion routines use exactly this algorithm to get each digit, repeating until the number is zero.

It will be the same no matter how many bytes you use, since base 10 doesn't directly map to base 2; that is, a base 10 digit may span from one byte to another.

>Shifting only works for powers of two.
By "shifting" I meant knocking off the least significant digit (division by 10, for example), not bitwise shifting specifically. Sorry for the confusion.

> By "shifting" I meant knocking off the least significant digit...
Yeah, I figured that's what you meant, but a total newbie would have confused it. Natural language is an enemy, alas. (I know it; I confuse people often enough when I try to make a short answer. And no one reads a long answer through...) :sweat: ;)

So im suppose to divide the al register by 10 to get 2 in it ? means i have to store it somewhere first so that i can div again to get the scond char? i shall try and post back later !

Each time you divide you loose the least-significant digit (the one in the ones position).

So if you want to get the tens position digit (2 in both our examples) you divide by 10 to move it to the ones position. Then use modulo 10 to extract the ones digit only.

This is pure math, so you'll have to think about it some. Good luck.

Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.

I am writing a java program that needs to execute shell commands, so I wrote a function that would take the command to execute as a string (ie: "mkdir ~/Folder1") and execute that command with the shell. Here is the function:

try
{
Runtime run = Runtime.getRuntime();
Process pr = ...

Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...