•      Sign In
• Create Account

### #Actual0Circle0

Posted 11 December 2012 - 01:31 AM

Do you want to return a number fro 1-8? The modulo (%) operator always returns a number from 0-7 for modulo 8, you probably want

x = (y % 8) + 1

or if you count from 1-8 not 0-7

x = ((y-1)%8) + 1

Not sure what you mean. HasSelection = X * 8 + Y. You don't know Y to get X from HasSelection.

Only way I can think of is to do it by hand rather than letting the computer do it for me.
//Like say x = 5 and y = 6
int HasSelection = 5 * 8 + 6; // or 46
int HSHolder = 0;
HSHolder = HasSelection / 8; // 46 / 8 = (int)5.75 = 5
y = ((HasSelection - 1) / 8 - HSHolder) * 8 + 1; // 45 / 8 = 5.625 - 5 = .625 * 8 = 5 + 1 = 6


### #110Circle0

Posted 11 December 2012 - 01:30 AM

Do you want to return a number fro 1-8? The modulo (%) operator always returns a number from 0-7 for modulo 8, you probably want

x = (y % 8) + 1

or if you count from 1-8 not 0-7

x = ((y-1)%8) + 1

Not sure what you mean. HasSelection = X * 8 + Y. You don't know Y to get X from HasSelection.

Only way I can think of is to do it by hand rather than letting the computer do it for me.
//Like say x = 5 and y = 6
int HasSelection = 5 * 8 + 6; // or 46
int HSHolder = 0;
HSHolder = HasSelection / 8; // 46 / 8 = (int)5.75 = 5
y = ((((HasSelection - 1) / 8) - HSHolder) * 8) + 1; // 45 / 8 = 5.625 - 5 = .625 * 8 = 5 + 1 = 6


### #100Circle0

Posted 11 December 2012 - 01:28 AM

Do you want to return a number fro 1-8? The modulo (%) operator always returns a number from 0-7 for modulo 8, you probably want

x = (y % 8) + 1

or if you count from 1-8 not 0-7

x = ((y-1)%8) + 1

Not sure what you mean. HasSelection = X * 8 + Y. You don't know Y to get X from HasSelection.

Only way I can think of is to do it by hand rather than letting the computer do it for me.
//Like say x = 5 and y = 6
int HasSelection = 5 * 8 + 6; // or 46
int HSHolder = 0;
HSHolder = HasSelection / 8; // 46 / 8 = (int)5.75 = 5
y = ((((HasSelection - 1) / 8) - HSHolder) * 8) + 1; // 5.75 - 5 = .75 * 8 = 6


### #90Circle0

Posted 11 December 2012 - 01:28 AM

Do you want to return a number fro 1-8? The modulo (%) operator always returns a number from 0-7 for modulo 8, you probably want

x = (y % 8) + 1

or if you count from 1-8 not 0-7

x = ((y-1)%8) + 1

Not sure what you mean. HasSelection = X * 8 + Y. You don't know Y to get X from HasSelection.

Only way I can think of is to do it by hand rather than letting the computer do it for me.
//Like say x = 5 and y = 6
int HasSelection = 5 * 8 + 6; // or 46
int HSHolder = 0;
HSHolder = HasSelection / 8; // 46 / 8 = (int)5.75 = 5
y = ((((HasSelection - 1) / 8) - HSHolder) * 8) + 1; // 5.75 - 5 = .75 * 8 = 6



### #80Circle0

Posted 11 December 2012 - 01:27 AM

Do you want to return a number fro 1-8? The modulo (%) operator always returns a number from 0-7 for modulo 8, you probably want

x = (y % 8) + 1

or if you count from 1-8 not 0-7

x = ((y-1)%8) + 1

Not sure what you mean. HasSelection = X * 8 + Y. You don't know Y to get X from HasSelection.

Only way I can think of is to do it by hand rather than letting the computer do it for me.
//Like say x = 5 and y = 6
int HasSelection = 5 * 8 + 6; // or 46
int HSHolder = 0;
HSHolder = HasSelection / 8; // 46 / 8 = (int)5.75 = 5
y = ((HasSelection / 8) - HSHolder) * 8; // 5.75 - 5 = .75 * 8 = 6
if (y == 0)
y = 8;


### #70Circle0

Posted 11 December 2012 - 01:18 AM

Do you want to return a number fro 1-8? The modulo (%) operator always returns a number from 0-7 for modulo 8, you probably want

x = (y % 8) + 1

or if you count from 1-8 not 0-7

x = ((y-1)%8) + 1

Not sure what you mean. HasSelection = X * 8 + Y. You don't know Y to get X from HasSelection.

Only way I can think of is to do it by hand rather than letting the computer do it for me.
//Like say x = 5 and y = 6
int HasSelection = 5 * 8 + 6; // or 46
int HSHolder = 0;
HSHolder = HasSelection / 8; // 46 / 8 = (int)5.75 = 5
y = ((HasSelection / 8) - HSHolder) * 8; // 5.75 - 5 = .75 * 8 = 6


PARTNERS