[flexcoders] Re: Number data type rounding/flooring with FDS and Java

2007-05-17 Thread alteraa
Thanks for the feedback Pete -- actually it turned out to be a line in
the DAO object that was doing the rounding.  I figured when I couldn't
find anything on the web that it must be my typical dumb error and not
something common.

However the part I mention in my first response is still valid, where
Number(textInput.text) is different from txtInput.text as Number.
 The as Number cast does round off the value to the nearest integer.

--- In flexcoders@yahoogroups.com, Peter Farland [EMAIL PROTECTED] wrote:

 Sorry I missed this post originally, is there any chance that you could
 email me a small test case directly... [EMAIL PROTECTED]
  
 Thanks,
  
Pete
 
 
 
 From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
 Behalf Of alteraa
 Sent: Friday, May 11, 2007 1:46 PM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] Number data type rounding/flooring with FDS and
 Java
 
 
 
 Hi, simple problem. I have a strongly-typed VO with a property
 value as a Number on the Flex side, and a Double on the Java side. 
 In the database the value is, let's say 5.20, but when I view the data
 in a DataGrid it floors the value to 5.
 
 I'm using a dataService to fill the ArrayCollection that holds the VOs
 and the VO class in ActionScript does have the [Managed]
 [RemoteClass(alias=] syntax. This works fine for all the data types
 I've used so far until I got to Number.
 
 I figure it's something simple I'm doing wrong, like maybe not
 specifying the number of decimal points that should be displayed?
 
 Also, in a related question, what's the best way to have the user
 input a Number value into a text input field, since TextInput.text is
 String data?
 
 Thanks!





RE: [flexcoders] Re: Number data type rounding/flooring with FDS and Java

2007-05-17 Thread Peter Farland
The as operator is not really the same as a conversion function. If the
expression is not of the specified datatype it usually returns null.
Number cannot be null, so I'd expect it to result in 0.
 
However, implicit coercion rules were added to the as operator in
ECMAScript 4 (and hence AS3)... but I'm not sure if String - Number is
intended to be one of these?
 
I decided the best way to know was to write my own test... 
 
var s:String = 5.20;
var n:Number = s as Number;
trace(n =  + n + \n\n);
 
Prints:
 
n = 0
 
So, you must be seeing this occur in different scenario? 
 
 
 
 
 
 
 


[flexcoders] Re: Number data type rounding/flooring with FDS and Java

2007-05-11 Thread alteraa
Actually I think I solved my second question, using

Number(txtValueInput.text)   instead of   txtValueInput.text as Number

The first one doesn't round off the value.  I'm not sure why these are
evaluated differently.