Integer to Byte Array

Questions regarding syntax

Integer to Byte Array

Postby nighthawk » Sun Feb 06, 2011 9:07 pm

Hi to all.

I'm testing Kbasic for future use and I'd like to know in which way i can subdivide an integer into an array of 4 bytes.

I'm trying the shift operand method without success.

Can anyone help me?

Best regards

NH.
nighthawk
 
Posts: 4
Joined: Sun Feb 06, 2011 9:02 pm

Re: Integer to Byte Array

Postby Henning » Sun Feb 06, 2011 11:53 pm

Just off my head,

Byte(0) = Integer And 255
Byte(1) = (Integer \ 256) And 255
Byte(2) = (Integer \ 65536) And 255
Byte(3) = (Integer \ 16777216) And 255

/Henning
Henning
 
Posts: 262
Joined: Mon Feb 09, 2009 12:03 am
Location: Sweden

Re: Integer to Byte Array

Postby nighthawk » Wed Feb 09, 2011 10:45 am

Many many thanks

iIt works!
nighthawk
 
Posts: 4
Joined: Sun Feb 06, 2011 9:02 pm


Return to Coding Questions

cron