| Subject: Re: [xsl] Implicit casting from double to float From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx> Date: Wed, 7 Jan 2009 09:58:27 +0000 | 
2009/1/7 Mukul Gandhi <gandhi.mukul@xxxxxxxxx>:
> Hi all,
>   When I ran the following XSLT 2.0 code, with Saxon 9.x
>
> <xsl:variable name="num1" select="xs:double('1e4')" as="xs:double" />
> <xsl:variable name="num2" select="$num1" as="xs:float" />
> <xsl:value-of select="$num2" />
>
> I get the output,
>
> 10000
>
> The XSLT 2.0 processor has no problem doing this operation. No warning
> is produced either.
>
> But a similar operation in Java is a serious compile time error,
>
> Please consider this Java fragment,
>
> float num = (double)1e4;
> System.out.println(num);
>
> This Java fragment doesn't compile, and following error is generated,
>
> test.java:3: possible loss of precision
> found   : double
> required: float
>
> float num = (double)1e4;
>                 ^
>
> Could somebody please explain this behavior with the XSLT 2.0 system.
I guess it's more like:
Double d = 1e4;
Float f = d.floatValue();
-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/
| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| [xsl] Implicit casting from double , Mukul Gandhi | Thread | Re: [xsl] Implicit casting from dou, Mukul Gandhi | 
| [xsl] Implicit casting from double , Mukul Gandhi | Date | Re: [xsl] Implicit casting from dou, Mukul Gandhi | 
| Month |