From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 815B57EE25 for ; Tue, 5 Nov 2013 04:54:45 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of ivg@ieee.org) identity=pra; client-ip=209.85.215.54; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="ivg@ieee.org"; x-conformance=sidf_compatible Received-SPF: PermError (mail3-smtp-sop.national.inria.fr: cannot correctly interpret sender authenticity information from domain of ivg@ieee.org) identity=mailfrom; client-ip=209.85.215.54; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="ivg@ieee.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-la0-f54.google.com) identity=helo; client-ip=209.85.215.54; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="postmaster@mail-la0-f54.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjQDAMdqeFLRVdc2lGdsb2JhbABZw02BKBYOAQEBAQcLCwkSKoIlAQEEATo/BQsLISUPAQQgAQUBIhOHewYEAZ9snkKOGIEzB4QuA4k6jlCKRIVZQYRWgWQ X-IPAS-Result: AjQDAMdqeFLRVdc2lGdsb2JhbABZw02BKBYOAQEBAQcLCwkSKoIlAQEEATo/BQsLISUPAQQgAQUBIhOHewYEAZ9snkKOGIEzB4QuA4k6jlCKRIVZQYRWgWQ X-IronPort-AV: E=Sophos;i="4.93,637,1378850400"; d="scan'208";a="33748286" Received: from mail-la0-f54.google.com ([209.85.215.54]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 05 Nov 2013 04:54:44 +0100 Received: by mail-la0-f54.google.com with SMTP id n7so2960649lam.41 for ; Mon, 04 Nov 2013 19:54:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=0oAqGobPGTV4AgEMolliFzMUBoctD2P8H6FyHEAAvdk=; b=Z0v894vqqhwhVEzzhewUIdjXyLOEt9Go2G/KcLqzGtBhW/Cu5s9lkvoDnMLv8m8gzd hy9Dlars8GXutv98QB7oE2xH9t8PWzTZ04r/q6Ip7NQkpCLqJP+nnv7/NrENn3aLl0mH rBoXuPc+H1gjddy99CIUPorzrOhlH/JHulr4TQXT66vfAsxLkEKXtJ/yCW+iHhQclXjv oTiaXgYc2JGYUbo/MWEGBrCBmYOkhf97jOccZe5IDU8SsURC5GQXy7heKHXDCSJ2Xs/r 0SlPpfQh5aytEWMc1GOt/HV95UyFjd91+V+USg2sH6oZVpirt9btMfUsaWD7N+zBuc5g RDKw== X-Gm-Message-State: ALoCoQkTY5w14zrMYjeMiBfkzAuYn2nNkSiA2hlVseFLNvTBswEQmdnf1z08V3vnjqVPNxoKruOn X-Received: by 10.152.5.69 with SMTP id q5mr38281laq.46.1383623683765; Mon, 04 Nov 2013 19:54:43 -0800 (PST) Received: from golf.niidar.ru.niidar.ru ([109.188.124.173]) by mx.google.com with ESMTPSA id 8sm25814028laq.5.2013.11.04.19.54.42 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Mon, 04 Nov 2013 19:54:43 -0800 (PST) From: Ivan Gotovchits To: Nicolas Trangez Cc: caml-list@inria.fr References: <1383605662.24373.7.camel@tau.nicolast.be> Date: Tue, 05 Nov 2013 07:54:37 +0400 In-Reply-To: <1383605662.24373.7.camel@tau.nicolast.be> (Nicolas Trangez's message of "Mon, 04 Nov 2013 23:54:22 +0100") Message-ID: <87a9hjmrk2.fsf@golf.niidar.ru> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Caml-list] Bug in caml_string_get16? Nicolas Trangez writes: > What would you expect to be the output of this code? It should fail :) In a string literal any symbol that you can type with your keyboard is stored in a special encoding called ASCII. With "1" you have just created a string containig a single byte with a value 49. So, first off all, your string is too short, because it has length of 1, when int16 obviously needs two bytes of storage space. If you really interested, binary 1 will be represented in a memory of a little endian computer like this: "\x01\x00". The special escape symbol "\" allows us to type untypable. The the code open EndianString let d = LittleEndian.get_int16 "\x01\x00" 0 will yield: val d : int = 1 By the way, if we try your string (with a more correct invocation): open EndianString let d = LittleEndian.get_int8 "1" 0 we will got: val d : int = 49 Futher reading: 1. man ascii 2. wikipedia article on endianess Good luck! -- (__) (oo) /------\/ / | || * /\---/\ ~~ ~~ ...."Have you mooed today?"...