Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Memblock trubble

Author
Message
Blazer
23
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: United States
Posted: 6th Apr 2003 23:43
I have 2 float values, the X and Z positions of an object. I want to combine them, send them as an integer online, then other people need to seperate them and position the object there. How do I combine and seperate them?

ps: my last 3 havent been answered, plese answere this
As I walk through the vally of the shadow of death, I will fear no evil.
- Psalms 23:4
Hell IVIonkey
23
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 7th Apr 2003 00:27
Not sure about floats, as they often tend to use up all place values in the variable number. You may want to cut off the decimal values after a certain number (experiment to find out how many). I've done this many times with limited-ranged ints though:

If you have "foo" which varies between 0 and 99, and "bar" which varies also between 0 and 99, you can say: combined=foo+100*bar, send along baz, and then separate the values again with bar=int(combined/100) and foo=combined-(bar*100). I don't have time to test this, but this is the general idea.
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 7th Apr 2003 01:22
this can't be done in DarkBasic standard/enhanced... atleast not easily, or to any decent level of accuracy.



you use them like so... say you need 2 word values combined into a dword
word = 65535 max
dword = 4,294,967,295 (but in db is an integer which is -2147483647 -> 2147483647)

and you'd use it like

result = BitLeft(int(floatZ#),8)+(int(floatX#))
floatZ# = BitRight(result,8)*1.0
floatX# = (result - int(floatZ))*1.0

as long as the value provided are under 255.0 you'll be fine with that...
to find out what you can actually fit into how many bytes do with

sqrt(int(fValue))

for 255.0 you'll return an 8 so thats the stepping you take

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?

Login to post a reply

Server time is: 2026-06-11 15:09:10
Your offset time is: 2026-06-11 15:09:10