From: Jose on 22 Jul 2010 13:22 Hello to everyone, why when i have to send 1 integer, i.e the number 5, i have to send 4 bytes...i.e...why 1 integer correspond with 4 bytes, and not 1 byte, thank you in advance?
From: us on 22 Jul 2010 13:31 "Jose " <jose.l.vega(a)gmail.com> wrote in message <i29uoe$5la$1(a)fred.mathworks.com>... > Hello to everyone, why when i have to send 1 integer, i.e the number 5, i have to send 4 bytes...i.e...why 1 integer correspond with 4 bytes, and not 1 byte, thank you > in advance? a hint: help int8; % <- or: UINT8 % eg, v=int8(5); whos v; %{ Name Size Bytes Class Attributes v 1x1 1 int8 %} us
From: Sean on 22 Jul 2010 13:33 "Jose " <jose.l.vega(a)gmail.com> wrote in message <i29uoe$5la$1(a)fred.mathworks.com>... > Hello to everyone, why when i have to send 1 integer, i.e the number 5, i have to send 4 bytes...i.e...why 1 integer correspond with 4 bytes, and not 1 byte, thank you > in advance? >>class(your_integer) it's either a 32bit integer or a single. If it's between [0, 255] recast it as an unsigned 8bit integer: uint8(your_integer);
From: Walter Roberson on 22 Jul 2010 13:55 Jose wrote: > Hello to everyone, why when i have to send 1 integer, i.e the number 5, > i have to send 4 bytes...i.e...why 1 integer correspond with 4 bytes, > and not 1 byte, thank you > in advance? Please expand on what you mean by "send" for the purposes of your question? Are each of the values you need to "send" small enough to fit within single bytes? If not, then is the pattern of which values will be larger known in advance? If the values you need to "send" may vary in size then there are techniques that can be used to vary the amount of data that needs to be sent, but these techniques require specific code to read the values afterwards and are not compatible with standard data storage or transmission interfaces; whether the techniques will reduce the total amount of data to be "sent" will depend upon the statistical average length of the data. For more information about these kinds of techniques, I recommend the book "Text Compression" by Bell, Cleary, and Witten. In particular, Cleary and Witten have written a number of papers on data compression techniques.
From: Jose on 22 Jul 2010 14:13
Walter Roberson <roberson(a)hushmail.com> wrote in message <i2a0ua$8m3$1(a)canopus.cc.umanitoba.ca>... > Jose wrote: > > Hello to everyone, why when i have to send 1 integer, i.e the number 5, > > i have to send 4 bytes...i.e...why 1 integer correspond with 4 bytes, > > and not 1 byte, thank you > > in advance? > > Please expand on what you mean by "send" for the purposes of your question? > > Are each of the values you need to "send" small enough to fit within single > bytes? If not, then is the pattern of which values will be larger known in > advance? > > If the values you need to "send" may vary in size then there are techniques > that can be used to vary the amount of data that needs to be sent, but these > techniques require specific code to read the values afterwards and are not > compatible with standard data storage or transmission interfaces; whether the > techniques will reduce the total amount of data to be "sent" will depend upon > the statistical average length of the data. For more information about these > kinds of techniques, I recommend the book "Text Compression" by Bell, Cleary, > and Witten. In particular, Cleary and Witten have written a number of papers > on data compression techniques. ok, guys, I understood...for default, when i am writing in my matlab v=5...is the same as v=uint64(5)...it means 1 integer correspond to 8 bytes (64 bits). Cheers guys. |