Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Dário Abdulrehman" <drehman31@gmail.com>
To: "Olivier Andrieu" <oandrieu@nerim.net>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] reading/writing binary data
Date: Tue, 21 Nov 2006 13:29:23 +0000	[thread overview]
Message-ID: <6aeedf580611210529k57456af5y5e321e0670c26fe0@mail.gmail.com> (raw)
In-Reply-To: <32511.213.30.139.86.1164114914.squirrel@webmail.nerim.net>

[-- Attachment #1: Type: text/plain, Size: 1348 bytes --]

On 11/21/06, Olivier Andrieu <oandrieu@nerim.net> wrote:
>
> > I am writing a program that encodes data in 32 bit ints.  Ideally I
> would
> > like to have 32 bit unsigned ints, but OCaml only has 31 bit signed
> ints.
>
> It also has 32 bits signed ints (and 64 bits).


Yes but the type int32 is not as efficient as int and I have huge data file.
>From the reference manual: " Performance notice: values of type int32 occupy
more memory space than values of type int, and arithmetic operations on
int32 are generally slower than those on int. Use int32 only when the
application requires exact 32-bit arithmetic."



> I have a large binary file with the data that I will mmap with the
> > Bigarray.Array1.map_file function.
> >
> > When I test the following code I am puzzled by the fact that Ocaml
> doesn't
> > give me back the int in the same format as I wrote it.
> >
> > Why doesn't OCaml read back data in the same format?
>
> because `output_binary_int' uses a big-endian encoding (cf. the reference
> manual) whereas Bigarray.map_file uses the native endianess (probably
> little-endian in your case).
>
> Don't use different methods to write your data and read it back !


Is there some library for writing binary int (not int32) that writes the
data in little endian (I think map_file reads it back in little endian on my
processor) ?

[-- Attachment #2: Type: text/html, Size: 2013 bytes --]

  reply	other threads:[~2006-11-21 13:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-21 11:34 Dário Abdulrehman
2006-11-21 13:15 ` [Caml-list] " Olivier Andrieu
2006-11-21 13:29   ` Dário Abdulrehman [this message]
2006-11-21 13:56     ` Dmitry Bely
2006-11-21 14:10       ` Jon Harrop
2006-11-21 19:57         ` Florian Hars

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6aeedf580611210529k57456af5y5e321e0670c26fe0@mail.gmail.com \
    --to=drehman31@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=oandrieu@nerim.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox