Re: [Pyobjc-dev] NSDecimalNumber to the next level
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2004-03-09 17:21:10
|
On 9-mrt-04, at 18:02, Pierce T.Wetter III wrote: > > > I want to take NSDecimalNumber to the next level. > > History: > > 1.0. > > NSDecimalNumber is wrapped as identical to CFNumber, which turns > out not work. > > 1.1 > > NSDecimalNumbers are passed through untransformed, you can use: > > dv=obj.doubleValue() to convert them to Python doubles, then: > > NSDecimalNumber.numberWithDouble(dv) to convert them back. This had > to happen because the type information was getting lost, and the > values passed back to Objective-C were plain CFNumber classes, which > didn't implement NSDecimalNumber.decimalNumberByAdding_(dv), etc. The type info should not get lost, NSDecimalNumber and NSDecimal (the C type backing the NSDecimalNumber class) should work correctly as numbers, including save coercions. I explicitly disabled implicit coercion from NSDecimal{Number,} to and from float because you might loose precision that way. If this doesn't work you found a bug that should be fixed. Ronald |