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 → flex%?=tenths, hundredth, thousandths...
flex%?=tenths, hundredth, thousandths...
2005-01-13, 5:15 AM #1
Hi!
I need some help. I wish to get a number from a flex value. You know the way that the CTF cogs get the hundreds, tens and units from a score, well, I wish to get the tenths, hundredths, thousandths, tenthousandths, hundredthousandths, and millionths from a flex speed and show them on number surfaces. Please help?

/Edward
Edward's Cognative Hazards
2005-01-13, 5:36 AM #2
The modulus operator is what you seek. (% in cog) Check datamaster. It returns the remainder of a division in cog.
-El Scorcho

"Its dodgeball time!" -Stormy Waters
2005-01-13, 5:47 AM #3
Yes, DM says what it is, but doesn't say what is needed to get certain numbers and onto 8 seperate surfaces. As the title sort of indicates, I haven't the fogiest what to % the flex with to get the stuff under the decimal point.

/Edward
Edward's Cognative Hazards
2005-01-14, 10:25 AM #4
Code:
SetWallCel(limit1, score_limit / 100);
SetWallCel(limit2, (score_limit % 100) / 10);
SetWallCel(limit3, score_limit % 10);


Ok, see these 3 lines? They're used to display the score limit mats correctly.

The first one will get you hundreds, 2nd tens, and 3rd one is Ones. Follow the math and it should make sense. :)

Oh, and don't worry about decimal. JK will ignore it all if you save the return value into an int. :)
-Hell Raiser
2005-01-14, 11:47 AM #5
Actually, I've found that to be untrue. If you save it into an int, JK seems to convert the int into a flex to hold the data it's given. I've attached a cog which will show this. There's a way to truncate, formula, and Zeq had it.

(For things like mats though, since an int is required, JK seems to then truncate for the appropriate cel)
_ _ _____________ _ _
Wolf Moon
Cast Your Spell On Me
Beware
The Woods At Night
The Wolf Has Come
2005-01-14, 12:07 PM #6
Greate! Figured it out! flex*10^DecimalPoints%10
Edward's Cognative Hazards
2005-01-16, 12:58 PM #7
This syntax in cog will not give the proper value:
flex*10^DecimalPoints%10

because it really means this:
(flex * 10) ^ (DecimalPoints % 10)
[The ^ operator is not 'power' but 'exclusive-or', and the end result would be a flex not an int (which is okay if the result will be truncated where it is used).]

In cog, use this:
tenths = flex * 10 % 10;
hundredths = flex * 100 % 10;
thousandths = flex * 1000 % 10;
ten-thousandths = flex * 10000 % 10;
hundred-thousandths = flex * 100000 % 10;
millionths = flex * 1000000 % 10;

Truncate existing flex: result = flexval - (flexval % 1);

:)
2005-01-16, 2:22 PM #8
Yes, well, I wrote ^ because I knew what it meant in mathamatical terms. Didn't mean it to be taken in COG terms.
Edward's Cognative Hazards

↑ Up to the top!