Re: Unsigned integers?

From: Sven LUTHER (luther@dpt-info.u-strasbg.fr)
Date: Wed Mar 22 2000 - 17:22:15 MET

  • Next message: Jean-Christophe Filliatre: "Re: Unsigned integers?"

    On Wed, Mar 22, 2000 at 09:22:15AM +1100, John Max Skaller wrote:
    > I have some code for processing ISO-10646 characters and UTF-8,
    > which uses caml integers. ISO-10646 has 2^31 code points, which
    > can be covered by caml integers on a 32bit machine. Using an
    > unboxed type is mandatory for performance.
    >
    > Unfortunately, caml integers are signed, which makes most of the
    > code I have written wrong (I haven't taken the care to handle
    > integers over 2^30 correctly).
    >
    > What is the best way to handle this problem?
    > Would a (standard?) library module (written in C), that treats
    > integers as unsigned be a reasonable solution?
    >
    > [This may require writing 'uint_add x y' instead of 'x+y',
    > but that doesn't matter in the above mentioned application,
    > since the integers are being used to represent characters]

    Just use the caml integer and ignore the fact that they are signed ?

    after the moto : that doesn't matter in the above mentioned application,
    since the integers are being used to represent characters]

    But then i don't know what you use it for ...

    And also, you would have to check exactly how integer overflow work, but in my
    experience max_int+1 = min_int.

    Friendly,

    Sven LUTHER



    This archive was generated by hypermail 2b29 : Wed Mar 22 2000 - 19:24:37 MET