Mercurial > hg > octave-lyh
changeset 6435:71888a0ab040
[project @ 2007-03-23 14:17:02 by dbateman]
author | dbateman |
---|---|
date | Fri, 23 Mar 2007 14:17:02 +0000 |
parents | 7caa5942d4da |
children | f1f2e0de340a |
files | liboctave/ChangeLog liboctave/oct-rand.cc |
diffstat | 2 files changed, 35 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2007-03-23 David Bateman <dbateman@free.fr> + + * oct-rand.cc (octave_rand::seed): Seed differently for big and + little endian. + 2007-03-15 John W. Eaton <jwe@octave.org> * lo-mappers.cc (acos): Use formula similar to what we use for asin.
--- a/liboctave/oct-rand.cc +++ b/liboctave/oct-rand.cc @@ -36,6 +36,7 @@ #include "randmtzig.h" #include "randpoisson.h" #include "randgamma.h" +#include "mach-info.h" // Possible distributions of random numbers. This was handled with an // enum, but unwind_protecting that doesn't work so well. @@ -152,7 +153,19 @@ union d2i { double d; octave_idx_type i[2]; }; union d2i u; - F77_FUNC (getsd, GETSD) (u.i[0], u.i[1]); + + oct_mach_info::float_format ff = oct_mach_info::native_float_format (); + + switch (ff) + { + case oct_mach_info::flt_fmt_ieee_big_endian: + F77_FUNC (getsd, GETSD) (u.i[1], u.i[0]); + break; + default: + F77_FUNC (getsd, GETSD) (u.i[0], u.i[1]); + break; + } + return u.d; } @@ -162,11 +175,25 @@ use_old_generators = true; maybe_initialize (); + int i0, i1; union d2i { double d; octave_idx_type i[2]; }; union d2i u; u.d = s; - int i0 = force_to_fit_range (u.i[0], 1, 2147483563); - int i1 = force_to_fit_range (u.i[1], 1, 2147483399); + + oct_mach_info::float_format ff = oct_mach_info::native_float_format (); + + switch (ff) + { + case oct_mach_info::flt_fmt_ieee_big_endian: + i1 = force_to_fit_range (u.i[0], 1, 2147483563); + i0 = force_to_fit_range (u.i[1], 1, 2147483399); + break; + default: + i0 = force_to_fit_range (u.i[0], 1, 2147483563); + i1 = force_to_fit_range (u.i[1], 1, 2147483399); + break; + } + F77_FUNC (setsd, SETSD) (i0, i1); }