<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">On 10 January 2011 16:36, Antoine Latter <<a href="mailto:aslatter@gmail.com">aslatter@gmail.com</a>> wrote:<br>
<br>
> On Mon, Jan 10, 2011 at 10:17 AM, Aaron Gray <<a href="mailto:aaronngray.lists@gmail.com">aaronngray.lists@gmail.com</a>><br>
> wrote:<br>
> > On 10 January 2011 16:13, Daniel Fischer <<br>
> <a href="mailto:daniel.is.fischer@googlemail.com">daniel.is.fischer@googlemail.com</a>><br>
> > wrote:<br>
> >><br>
> >> On Monday 10 January 2011 16:45:36, Aaron Gray wrote:<br>
> >> ><br>
> >> > This is interesting, what does the following line do :-<br>
> >> ><br>
> >> > data Int24 = I24# Int# deriving (Eq, Ord)<br>
> >> ><br>
> >> > regarding the I24# and Int#, are these inbuilt ?<br>
> >><br>
> >> Int# is the raw machine int (4 or 8 bytes) and I24# is the constructor.<br>
> >> GHC<br>
> >> uses the magic hash '#' to denote raw unboxed types (and the<br>
> constructors<br>
> >> making ordinary boxed Haskell types from these, e.g. there's<br>
> >><br>
> >> data Int = I# Int#<br>
> >> data Word = W# Word#<br>
> >> data Double = D# Double#<br>
> >><br>
> >> and more defined in base [GHC.Types, GHC.Word]).<br>
> ><br>
> > So the 24 bit value is actually stored as a 32bit value. Meaning I will<br>
> have<br>
> > to do my own IO reader and writer code to a ByteString.<br>
> > Thanks,<br>
> > Aaron<br>
> ><br>
><br>
> I don't think so - the Storable instance provided for the Int24 type<br>
> peeks and pokes 24-bit values. At least, that what I understand John's<br>
> earlier message to mean.<br>
<br>
<br>
Yes looking at the code it does support 24bit peeks and pokes.<br></blockquote><div><br></div><div>This is correct (at least it's how it's meant to work). 24bit values are represented as 32bit words for ops, but peeks and pokes are 24bit.</div>
<div><br></div><div>If all you want to do is read/write 24bit values there's nothing wrong with binary, but if you ever want to use them the Word24 and Int24 types are nice to have.</div><div><br></div><div>John</div>
</div>