On 5/8/05, PhiHo Hoang <[EMAIL PROTECTED]> wrote: > Jim Hugunin wrote: > > > PhiHo Hoang wrote: > > > Why 66.6 cannot be converted to System.Int32 ? > > 66.6 can be both explicitly converted to an int and compared to one. > > > >>> int(66.6) > > 66 > > >>> 12 < 66.6 > > True > > >>> 66.6 < 12 > > False > > > It's a good thing that 66.6 won't be implicitly converted to an int > > since that would lose precision. > > > > >>> a > > > [333, 1234.5, 1, 333, -1, 66.6] > > > >>> a.sort() > > > System.InvalidOperationException: Failed to compare two elements in > > > the array. - > > > However, you're right that IronPython doesn't handle this correctly for > > sorting an array. We already have one bug for sorting mixed-type arrays > > (bug #63) but it's nice to add this case as well to the set we need to > > fix. > > Talking of precision, for sorting, wouldn't it be more precise to > convert int to float instead of float to int, when there is a mixture ? > > Thanks, > > PhiHo > > _______________________________________________ > users-ironpython.com mailing list > users-ironpython.com@lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >
Yeah, you could probably convert all the ints to floats during the comparison then convert them back afterward. -- Travis Watkins http://www.realistanew.com _______________________________________________ users-ironpython.com mailing list users-ironpython.com@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com