October 11, 2004 BUG: Sorting array of real's doesn't correctly sort things | ||||
---|---|---|---|---|
| ||||
The following code (Linux, 0.102) demonstrates that an array of real's is not sorted correctly: > import std.stdio; > int main() { > real[1000] array; > for(int i=999; i>=0; i--) > array[999-i] = (cast(real)i)/8; > real[] sorted_copy = array.dup; > sorted_copy.sort; > for(int i=0; i<1000; i++) > writef("%f\n", sorted_copy[i]); > return 0; > } The first several lines of ouput are > 0.375000 > 0.000000 > 0.500000 > 0.625000 > 0.250000 > 0.125000 > 2.000000 |
October 13, 2004 Re: Sorting array of real's doesn't correctly sort things | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russ Lewis | Russ Lewis schrieb: > The following code (Linux, 0.102) demonstrates that an array of real's > is not sorted correctly: > > > import std.stdio; > > > > int main() { > > real[1000] array; > > for(int i=999; i>=0; i--) > > array[999-i] = (cast(real)i)/8; > > > > real[] sorted_copy = array.dup; > > sorted_copy.sort; > > > > for(int i=0; i<1000; i++) > > writef("%f\n", sorted_copy[i]); > > > > return 0; > > } > > The first several lines of ouput are > > > 0.375000 > > 0.000000 > > 0.500000 > > 0.625000 > > 0.250000 > > 0.125000 > > 2.000000 added to destress as svn://svn.kuehne.cn/dstress/run/sort_03.d in addition the following striped down code segfaults: # real[10] array; # real[] copy = array.dup; # copy.sort; testcase svn://svn.kuehne.cn/dstress/run/dup_04.d Thomas |
Copyright © 1999-2021 by the D Language Foundation