[ 
https://issues.apache.org/jira/browse/TRINIDAD-1683?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12837043#action_12837043
 ] 

Cale Scholl commented on TRINIDAD-1683:
---------------------------------------

Since Java 1.5+ supports covariant return types, the return type of 
org.apache.myfaces.trinidad.convert.NumberConverter#getAsObject could have been 
Number instead of Object; this would have prevented the need for casting. 
However, if at this point we change the signature to return a Number, then any 
subclasses of NumberConverter that override getAsObject and return an Object 
would then have a contravariant return type, and thus break. 

We might still consider changing the signature of the private ClientConverter, 
org.apache.myfaces.trinidadinternal.convert.NumberConverter#getAsObject, to 
return a Number.

Java doesn't support casting between Number types, so returning a BigInteger 
instead of a Long could break someone's code (although theoretically we should 
have only supported casting to Number); it was decided to leave the return type 
as Long.

> client-side convertNumber causes loss of precision
> --------------------------------------------------
>
>                 Key: TRINIDAD-1683
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1683
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>          Components: Components
>    Affects Versions:  1.2.12-core
>            Reporter: Cale Scholl
>            Assignee: Gabrielle Crawford
>            Priority: Minor
>         Attachments: maxPrecision_1.2.12.2.patch, maxPrecision_trunk.patch
>
>
> ISSUE:
> ----------
> JS numbers are 64-bit values and thus only have 16 digits of precision; this 
> isn't enough to represent the max value of a Long, BigInteger, or BigDecimal. 
> This means that when we convert a number string to object then back to string 
> on the client, we can lose precision, even though we wouldn't lose any 
> precision on the server.
> FIX:
> -----
> Only render a client converter if the input value is bound to a supported 
> type (Float, Double, Integer, Short, Byte). The JavaScript number is a 64-bit 
> floating type and has enough precision to represent any of these supported 
> types.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to