Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

float and bytecode #3199

Closed
vicuna opened this issue Feb 11, 2002 · 3 comments
Closed

float and bytecode #3199

vicuna opened this issue Feb 11, 2002 · 3 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Feb 11, 2002

Original bug ID: 883
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Christian Gillot
Version: 3.04
OS: Linux
Submission from: 80-24-20-121.uc.nombres.ttd.es (80.24.20.121)

This bug is related to the "not a bug/881".

I had the problem that floats got corrupted using the bytecode
runtime on the ARM :
ie. the following program :

let main () =
let x = 5.2 in
let y = 6.3 in
let z = x +. y in
print_float x;
print_string " + ";
print_float y;
print_string "=";
print_float z;
print_string "\n";;

main();;

generated the following output :

-9.25596534328e+61 + 4.66726164528e-62=-9.25596534328e+61

Not what was expected.
Later Xavier Leroy that it tested this on the skiffcluster (handhelds.org).

After some investigation I discovered that yes the skiffcluster5.handhelds.org
ocamlc compiler from Xavier worked on the foo.ml. But at the very same
time "float", the same program but compiled on my machine don't work as I put
it before.

So the point is that a x86 ocamlc-compiled bytecode program has corrupted
floats on the arm, and that it work in the other way ie. arm ocamlc-compiled
bytecode has corrupted floats executed on the x86.

Note that if you strip out the first line (#!....)
you get a different size for the same program :
float (x86 compiled) : 9110
foo (arm compiled) : 9108

So for 2 bytes I hope that it's trivial to fix, but I don't have the
expertise to fix it though.
Note that both x86 ocamlc and arm ocamlc are from version ocaml-3.04

Thanks a lot for your time,
Regards

@vicuna
Copy link
Author

vicuna commented Feb 12, 2002

Comment author: administrator

I had the problem that floats got corrupted using the bytecode
runtime on the ARM :
Later Xavier Leroy that it tested this on the skiffcluster (handhelds.org).

After some investigation I discovered that yes the skiffcluster5.handhelds.org
ocamlc compiler from Xavier worked on the foo.ml. But at the very same
time "float", the same program but compiled on my machine don't work as I put
it before.

Ah, you didn't say you were cross-compiling. This is a known problem
with ARM floating-point arithmetic: its double-precision floats are
neither little-endian nor big-endian. That is:

                    representation of 1.0

little-endian 00 00 00 00 00 00 f0 3f
big-endian 3f f0 00 00 00 00 00 00
ARM 00 00 f0 3f 00 00 00 00

The Caml bytecode interpreter can convert between little-endian and
big-endian formats (e.g. if you compiled on a l-e machine and run on a
b-e machine). But it cannot convert to/from the ARM format.

So, I'm afraid you have to compile on the ARM itself if your program
contains float literals.

  • Xavier Leroy

@vicuna
Copy link
Author

vicuna commented Feb 12, 2002

Comment author: administrator

Hi,

Ah, you didn't say you were cross-compiling. This is a known problem
Désolé je pensais que ça n'avait aucune incidence vu que il me semblait
le bytecode était complètement indépendant du système compilé.
with ARM floating-point arithmetic: its double-precision floats are
neither little-endian nor big-endian. That is:

                   representation of 1.0

little-endian 00 00 00 00 00 00 f0 3f
big-endian 3f f0 00 00 00 00 00 00
ARM 00 00 f0 3f 00 00 00 00

The Caml bytecode interpreter can convert between little-endian and
big-endian formats (e.g. if you compiled on a l-e machine and run on a
b-e machine). But it cannot convert to/from the ARM format.
Serait-il difficile de l'implémenter ? Bon d'accord tout est possible,
mais ça reste relatif. Si vous n'avez pas l'intention de le faire
dans un futur immédiat, pourriez-vous me donner quelques pistes
pour l'implémenter ? Je serais plus que content d'essayer de contribuer
à Ocaml de cette manière.

So, I'm afraid you have to compile on the ARM itself if your program
contains float literals.
Ça réduit considérablement l'intérêt du cross-compiler et vu la vitesse
de l'iPAQ c'est bien plus pratique de cross-compiler.

Cordialement,

--
Christian Gillot cgillot@gruposbd.com
GNU/Linux developer

@vicuna
Copy link
Author

vicuna commented Feb 19, 2002

Comment author: administrator

Fixed 2002-02-19 by XL

@vicuna vicuna closed this as completed Feb 19, 2002
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant