Re: WOWS or Cocoa bug?
Re: WOWS or Cocoa bug?
- Subject: Re: WOWS or Cocoa bug?
- From: Kieran Kelleher <email@hidden>
- Date: Sun, 5 Nov 2006 20:17:52 -0500
I have not looked at this in detail, but fit seems obvious to use
strings to pass accurate decimals and convert to BigDecimal for the
calculation.
new BigDecimal( String numberAsString )
NSDecimalNumber initWithString
On Nov 5, 2006, at 2:48 PM, Ricardo Strausz wrote:
On Nov 5, 2006, at 10:27 AM, Paul Lynch wrote:
On 5 Nov 2006, at 13:46, Ricardo Strausz wrote:
I am using doubles in both sides: the server and the client...
Shall I blame them?
You should. float and double are both floating point primitives
in java; double offers more precision (the number of significant
digits) than float. But, as pointed out, any type of float is
inherently precise.
If you want to create a calculator object, it is a good idea to
use BigDecimal. Java was originally designed as a PDA/set top box
language, and its roots often show. Treat this as an opportunity
to demonstrate the benefits of encapsulation in an object oriented
design :-).
This is easy to say... not so easy to implement.
The Java side is waiting for two double values which, in
particular, can be directly operated (they understand the + sign)
so, in order to operate with BigDecimals, the implementation on
that side most be re-implemented — and it is not enough to
instantiate the BigDecimals inside that method because the
"approximation-error" remains there. On the other side, the stubs
are also implemented using doubles, so a re-implementations is
needed also there; even worst, there is no equivalent to BigDecimal
in Objective-C (the closest is NSDecimalNumber).
Therefore, I am thinking in use strings to pass the values from the
client to the server...
is this the efficient way to do this?
Dino
Paul
On Nov 5, 2006, at 3:47 AM, Paul Lynch wrote:
On 5 Nov 2006, at 01:35, Ricardo Strausz wrote:
Playing with WOWS and Cocoa I found that even a simple sum, is
buggy...
I'd published the Calculator.java example from WO and consume
it with WebServicesCore.framework in a very straight-forward
way (the details are in http://strausz.blogspot.com/2006/11/
consuming-calculatorjava-ws.html ); while adding 3.4 to 6.6,
instead of 10.0 I did get 9.999998099999999 ... close, but not
correct =:+(
To whom I shall blame?
At a guess - blame floats.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden