# HG changeset patch # User dbateman # Date 1174659422 0 # Node ID 71888a0ab04073715db8c696b6b7fe38f3d820a3 # Parent 7caa5942d4dae89d8de578d497ce05a4f6ddda02 [project @ 2007-03-23 14:17:02 by dbateman] diff -r 7caa5942d4da -r 71888a0ab040 liboctave/ChangeLog --- a/liboctave/ChangeLog Fri Mar 23 13:59:29 2007 +0000 +++ b/liboctave/ChangeLog Fri Mar 23 14:17:02 2007 +0000 @@ -1,3 +1,8 @@ +2007-03-23 David Bateman + + * oct-rand.cc (octave_rand::seed): Seed differently for big and + little endian. + 2007-03-15 John W. Eaton * lo-mappers.cc (acos): Use formula similar to what we use for asin. diff -r 7caa5942d4da -r 71888a0ab040 liboctave/oct-rand.cc --- a/liboctave/oct-rand.cc Fri Mar 23 13:59:29 2007 +0000 +++ b/liboctave/oct-rand.cc Fri Mar 23 14:17:02 2007 +0000 @@ -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); }