The Daily Click ::. Forums ::. Klik Coding Help ::. Maths problem!
 

Post Reply  Post Oekaki 
 

Posted By Message

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
15th June, 2005 at 13:58:55 -

I've got a small maths problem. It's do do with Binary Object.

Basically, it reads values as signed integers, when I wanna read them as unsigned. This is a pain. I need some way (I did it once, but can't remember how) of converting them without using conditions (so it's all done in a formula). Can anyone help? I don't want to use Immediate If Object if I can avoid it.

For those who don't know, the problem with signing is this. A byte is basically like a counter in MMF, it can hold any number between 0 and 255. The problem is that if it's signed, they tweak it a bit so it can hold numbers between -128 and 127.

That means that if you add 1 every second, you'll see the value go up by 1. But when it gets to 128, it will switch into minus figures and start going *down* - it's horrible! Eg:

0
1
2
...
126
127
-128
-127
-126
-125
...
-3
-2
-1


See what I mean?

I need to find a way of converting this horrible signed number into a normal value, otherwise Binary object is useless to me.

 
191 / 9999 * 7 + 191 * 7

Fifth

Quadruped

Registered
  07/05/2003
Points
  5818

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
15th June, 2005 at 15:29:49 -

Yeah, I know the problem. The answer is simple:

( value + 256 ) mod 256

And you're set!

 
Go Moon!

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
15th June, 2005 at 18:40:56 -

Wow! I looked at that and thought "He's so misunderstood what I meant", but lo! It actually works!!

Thanks a million!

 
191 / 9999 * 7 + 191 * 7
   

Post Reply



 



Advertisement

Worth A Click