Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - little/big endian | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
User Post
elixirnova

Red Paratroopa
Level: 22

Posts: 34/177
EXP: 56507
For next: 1843

Since: 04-05-04
From: Midgar

Since last post: 1 day
Last activity: 1 day
Posted on 09-02-04 08:42 AM Link | Quote
hey im using little endian to store my level data ex 55 01 or ad 00 or fe 02
so i used
let byte2 = 01
and byte1 = 55 as in the example
(Byte2 * &H100) + Byte 1
so using that equation used the result is 155 and i cant figure out
how i am to convert it back to 55 01 for saving purposes O_o
any help im using VB.net
Monsty
Newcomer
Level: 5

Posts: 6/6
EXP: 357
For next: 172

Since: 03-21-04
From: USA

Since last post: 426 days
Last activity: 335 days
Posted on 09-02-04 09:33 AM Link | Quote
SwitchEnd = ((Number And &HFF) * &H100) And (Number \ &H100)

That value should switch the endian-ness of any two-byte number...I think. Didn't test.

EDIT:
D'oh, now I know why you ignored me. I put one wrong operator! Sure, you say it's all good now...but I needed to fix this, so here we go:

SwitchEnd = ((Number And &HFF) * &H100) Or (Number \ &H100)

Notice the And switch to Or? Yeah, that should fix it. Plus it should be mucho faster than anything involving modulus(if you have to do it a lot, anyways).


(edited by Monsty on 09-02-04 12:34 AM)
(edited by Monsty on 09-02-04 05:22 PM)
neotransotaku

Baby Mario
戻れたら、
誰も気が付く
Level: 87

Posts: 1313/4016
EXP: 6220548
For next: 172226

Since: 03-15-04
From: Outside of Time/Space

Since last post: 11 hours
Last activity: 1 hour
Posted on 09-02-04 11:55 AM Link | Quote
can't you just write back, 55 as the first byte and then 01 as the next byte to write back? as long as you write to file using bytes, then everything should be fine.
Dish

Spiny
Level: 38

Posts: 120/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 09-02-04 09:21 PM Link | Quote
If you're using VB you shouldn't have to worry about this at all... since VB will only run on Windows (a little endian system), if you save a multi-byte variable to a file, it will automatically write it as little endian. You'd only have to do any kind of swapping if you want to write it as big endian.
elixirnova

Red Paratroopa
Level: 22

Posts: 36/177
EXP: 56507
For next: 1843

Since: 04-05-04
From: Midgar

Since last post: 1 day
Last activity: 1 day
Posted on 09-03-04 01:15 AM Link | Quote
ah all fixed seamed i needed to learn two new operators modulus and int works fine now thanks everyone
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
Acmlm's Board - I2 Archive - Programming - little/big endian | |


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.009 seconds.