caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] float on 32 bits?
@ 2011-12-01 16:45 Pierre Vittet
  2011-12-01 17:57 ` Niki Yoshiuchi
  2011-12-02  1:46 ` Jon Harrop
  0 siblings, 2 replies; 4+ messages in thread
From: Pierre Vittet @ 2011-12-01 16:45 UTC (permalink / raw)
  To: caml-list

Hello!

I am using ocaml to analyse java bytecode 
(http://javalib.gforge.inria.fr/). The fact is that java has a float 
type which is coded on 32 bits and a double type which is coded on 64 
bits. I need to make corresponding types but ocaml only has a float 
coded on 64 bits (IEE 754 norm, which java respect too), so I don"t know 
how to get the float 32 bits.

Is there some Float32 module? I cannot just place my float 32 into a 
float 64 because I need to get same behaviour on basic operations.

Thanks!

Pierre Vittet

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] float on 32 bits?
  2011-12-01 16:45 [Caml-list] float on 32 bits? Pierre Vittet
@ 2011-12-01 17:57 ` Niki Yoshiuchi
  2011-12-02  1:46 ` Jon Harrop
  1 sibling, 0 replies; 4+ messages in thread
From: Niki Yoshiuchi @ 2011-12-01 17:57 UTC (permalink / raw)
  To: Pierre Vittet; +Cc: caml-list

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

OCaml Bigarrays support 32 bit floats, however when you are manipulating
them in OCaml code they are cast to 64 bit floats.  I am not aware of any
other modules that support 32 bit floats, although it wouldn't be that hard
to write your own with a C backend.

On Thu, Dec 1, 2011 at 11:45 AM, Pierre Vittet <piervit@pvittet.com> wrote:

> Hello!
>
> I am using ocaml to analyse java bytecode (http://javalib.gforge.inria.**
> fr/ <http://javalib.gforge.inria.fr/>). The fact is that java has a float
> type which is coded on 32 bits and a double type which is coded on 64 bits.
> I need to make corresponding types but ocaml only has a float coded on 64
> bits (IEE 754 norm, which java respect too), so I don"t know how to get the
> float 32 bits.
>
> Is there some Float32 module? I cannot just place my float 32 into a float
> 64 because I need to get same behaviour on basic operations.
>
> Thanks!
>
> Pierre Vittet
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/**wws/info/caml-list<https://sympa-roc.inria.fr/wws/info/caml-list>
> Beginner's list: http://groups.yahoo.com/group/**ocaml_beginners<http://groups.yahoo.com/group/ocaml_beginners>
> Bug reports: http://caml.inria.fr/bin/caml-**bugs<http://caml.inria.fr/bin/caml-bugs>
>
>

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [Caml-list] float on 32 bits?
  2011-12-01 16:45 [Caml-list] float on 32 bits? Pierre Vittet
  2011-12-01 17:57 ` Niki Yoshiuchi
@ 2011-12-02  1:46 ` Jon Harrop
  2011-12-02 14:07   ` Pierre Vittet
  1 sibling, 1 reply; 4+ messages in thread
From: Jon Harrop @ 2011-12-02  1:46 UTC (permalink / raw)
  To: 'Pierre Vittet', caml-list

You'll probably have to do a lot of work to get the same floating point behaviour from OCaml. Firstly, OCaml compiled with ocamlopt often retains 80 bits of precision when processing in registers. Secondly, the Java specification mandates more accurate handling of some functions, e.g. trigonometric functions. Note that floats are treated differently by code compiled with ocamlc and ocamlopt.

Cheers,
Jon.

> -----Original Message-----
> From: Pierre Vittet [mailto:piervit@pvittet.com]
> Sent: 01 December 2011 16:46
> To: caml-list@inria.fr
> Subject: [Caml-list] float on 32 bits?
> 
> Hello!
> 
> I am using ocaml to analyse java bytecode (http://javalib.gforge.inria.fr/). The
> fact is that java has a float type which is coded on 32 bits and a double type
> which is coded on 64 bits. I need to make corresponding types but ocaml only
> has a float coded on 64 bits (IEE 754 norm, which java respect too), so I don"t
> know how to get the float 32 bits.
> 
> Is there some Float32 module? I cannot just place my float 32 into a float 64
> because I need to get same behaviour on basic operations.
> 
> Thanks!
> 
> Pierre Vittet
> 
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] float on 32 bits?
  2011-12-02  1:46 ` Jon Harrop
@ 2011-12-02 14:07   ` Pierre Vittet
  0 siblings, 0 replies; 4+ messages in thread
From: Pierre Vittet @ 2011-12-02 14:07 UTC (permalink / raw)
  To: Jon Harrop, aplusbi, caml-list

Thanks for your answers (Jon and Niki).

I was not aware about that behaviour difference between ocamlc and 
ocamlopt...

Pierre

Le 02/12/2011 02:46, Jon Harrop a écrit :
> You'll probably have to do a lot of work to get the same floating point behaviour from OCaml. Firstly, OCaml compiled with ocamlopt often retains 80 bits of precision when processing in registers. Secondly, the Java specification mandates more accurate handling of some functions, e.g. trigonometric functions. Note that floats are treated differently by code compiled with ocamlc and ocamlopt.
>
> Cheers,
> Jon.
>
>> -----Original Message-----
>> From: Pierre Vittet [mailto:piervit@pvittet.com]
>> Sent: 01 December 2011 16:46
>> To: caml-list@inria.fr
>> Subject: [Caml-list] float on 32 bits?
>>
>> Hello!
>>
>> I am using ocaml to analyse java bytecode (http://javalib.gforge.inria.fr/). The
>> fact is that java has a float type which is coded on 32 bits and a double type
>> which is coded on 64 bits. I need to make corresponding types but ocaml only
>> has a float coded on 64 bits (IEE 754 norm, which java respect too), so I don"t
>> know how to get the float 32 bits.
>>
>> Is there some Float32 module? I cannot just place my float 32 into a float 64
>> because I need to get same behaviour on basic operations.
>>
>> Thanks!
>>
>> Pierre Vittet
>>
>> --
>> Caml-list mailing list.  Subscription management and archives:
>> https://sympa-roc.inria.fr/wws/info/caml-list
>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-12-02 14:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-01 16:45 [Caml-list] float on 32 bits? Pierre Vittet
2011-12-01 17:57 ` Niki Yoshiuchi
2011-12-02  1:46 ` Jon Harrop
2011-12-02 14:07   ` Pierre Vittet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).