[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Save/save_precision problem ?
From: |
Joao Cardoso |
Subject: |
Save/save_precision problem ? |
Date: |
Mon, 2 Oct 1995 06:09:52 +0100 (MET) |
Hi,
There seems to exist a problem with the save command with the -ascii option,
the save_precision option and (eventually) printf.
I noticed the problem when I could't reproduce Octave anwsers with an external
program feed from octave.
It seems that if the save_precision is too high (the default of 17 decimal
places) the saved variables are unrounded (yes...).
It does not seem to be a problem of internal rounding because of binary
inability to exactly represent decimal numbers.
Look bellow:
octave
Octave, version 1.1.1.
Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton.
This is free software with ABSOLUTELY NO WARRANTY.
For details, type `warranty'.
octave:1> load hemophil.asc
octave:2> hemophil
hemophil =
-0.00560 -0.16570 0.00000
-0.16980 -0.15850 0.00000
-0.34690 -0.18790 0.00000
-0.08940 0.00640 0.00000
...stuff deleted...
octave:3> save -ascii popo hemophil
octave:4> system("more popo")
# name: hemophil
# type: matrix
# rows: 75
# columns: 3
-0.0055999999999999999 -0.16569999999999999 0
-0.16980000000000001 -0.1585 0
-0.34689999999999999 -0.18790000000000001 0
-0.089399999999999993 0.0064000000000000003 0
-0.16789999999999999 0.071300000000000002 0
-0.083599999999999994 0.0106 0
octave:5> save_precision=5
save_precision = 5
octave:6> save -ascii popo hemophil
octave:7> system("more popo")
# name: hemophil
# type: matrix
# rows: 75
# columns: 3
-0.0056 -0.1657 0
-0.1698 -0.1585 0
-0.3469 -0.1879 0
-0.0894 0.0064 0
-0.1679 0.0713 0
-0.0836 0.0106 0
everyting from save_precision=5 to save_precision=15 goes OK.
save_precision = 16
octave:33> save -ascii popo hemophil
octave:34> system("more popo")
# name: hemophil
# type: matrix
# rows: 75
# columns: 3
-0.0056 -0.1657 0
-0.1698 -0.1585 0
-0.3469 -0.1879 0
-0.08939999999999999 0.0064 0
-0.1679 0.0713 0
-0.08359999999999999 0.0106 0
-0.1979 -0.0005 0
octave:35> save_precision=17
save_precision = 17
octave:36> save -ascii popo hemophil
octave:37> system("more popo")mophil
# name: hemophil
# type: matrix
# rows: 75
# columns: 3
-0.0055999999999999999 -0.16569999999999999 0
-0.16980000000000001 -0.1585 0
-0.34689999999999999 -0.18790000000000001 0
-0.089399999999999993 0.0064000000000000003 0
-0.16789999999999999 0.071300000000000002 0
-0.083599999999999994 0.0106 0
If it where an internal representation problem, this should be in error,
octave:39> format long
octave:40> hemophil
hemophil =
-0.005600000000000 -0.165700000000000 0.000000000000000
-0.169800000000000 -0.158500000000000 0.000000000000000
-0.346900000000000 -0.187900000000000 0.000000000000000
-0.089400000000000 0.006400000000000 0.000000000000000
octave:43> hemophil (4,1)
ans = -0.0894000000000000
octave:44> hemophil (4,1) - -0.0894000000000000
ans = 0
Well, is a new bug or is just binary inability to represent some decimal
numbers? If it is shouldn't be better to use a default save_precision
of 15 or lower?
No, I don't have a Pentium :-(
Thanks,
Joao
- Save/save_precision problem ?,
Joao Cardoso <=