Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Something wrong with my calculations?
Something wrong with my calculations?
2001-02-05, 9:40 AM #1
Here's a short summary of what I'm trying to do: I'm trying to defragment this integer - 210110131 into four integers: 2, 1011, 013, and 1. Here are my calculations:

For the first int I just run a 'bigger than or equals' check because the long integer is always smaller than 3*10^8 (the first digit is always 1 or 2).

For the three other ints, A, B and C, I run the following:

a = (longint - 200000000)/10000;
b = ((longint - 200000000) - (a*10000))/10;
c = ((longint - 200000000) - (a*10000)) - (b*10);

The problem is that the cog retrieves only A (it prints to screen 1011) but leaves B and C assigned with zero, instead of B = 13 and C = 1.

Is something wrong with the way I handle the integers?

[This message has been edited by Fardreamer (edited February 05, 2001).]
Dreams of a dreamer from afar to a fardreamer.
2001-02-06, 2:18 AM #2
How about you do this from the lower integer.

Code:
d = longint % 10;
c = (longint - longint % 10) / 10 % 1000;
b = (longint - longint % 10000) / 10000 % 10000;
a = (longint - longint % 100000000) / 100000000;


I think it does "%" then "-". If not, put brackets.

------------------
http://millennium.massassi.net/ - Millennium
2001-02-07, 2:59 AM #3
I tried that. For some bizarre reason, 210110131 % 10 gave me 8!!! (instead of 1). I wonder if % is really modulus and doesn't have a different function in cog.
Dreams of a dreamer from afar to a fardreamer.
2001-02-07, 4:50 AM #4
The value of that integer might be going over the limit of an integer that JK can handle.

In short, maybe the number is too big.

Try to print it out and see if it prints as is.

------------------
http://millennium.massassi.net/ - Millennium

[This message has been edited by Hideki (edited February 07, 2001).]
2001-02-07, 6:38 AM #5
Oh, no; it prints just fine, since the JK integer's range is "-2,147,483,648 to +2,147,483,648 signed 32 bit whole number".
Dreams of a dreamer from afar to a fardreamer.
2001-02-07, 1:17 PM #6
Let me see the cog.

or try "flex, thing, etc" [http://forums.massassi.net/html/wink.gif] might work.

------------------
http://millennium.massassi.net/ - Millennium

↑ Up to the top!