Re: Can I force precision loss?
From: Tony Morris (not_at_telling.you)
Date: 01/17/05
- Next message: AlexKay: "Re: Hibernate alternatives"
- Previous message: Andrew Thompson: "Re: Executable JAR"
- In reply to: Mike Schilling: "Re: Can I force precision loss?"
- Next in thread: Yu SONG: "Re: Can I force precision loss?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 17 Jan 2005 08:27:19 GMT
"Mike Schilling" <mscottschilling@hotmail.com> wrote in message
news:rFCGd.11064$wZ2.2782@newssvr13.news.prodigy.com...
>
> "Ryan Stewart" <zzanNOtozz@gSPAMo.com> wrote in message
> news:YcmdnVmpkZjPfXfcRVn-vw@texas.net...
> > "stevek" <someone@somewhere.org> wrote in message
> > news:7dyGd.14118$S11.1092@bgtnsc04-news.ops.worldnet.att.net...
> > [...]
> >> RandomCheck.java:21: possible loss of precision
> > [...]
> > It's called casting:
> >
> > long l = 500;
> > int i = (int) l;
>
>
> Casting long to int doesn't affect precsision, of course; either the
> conversion is exact or the result is completely different.
>
> double d;
> float f = (float)d;
>
> would reduce precision.
>
>
The compiler is issuing you with an error because your type conversion loses
information (64-bit type can't fit in a 32-bit type obviously).
By providing the explicit cast, you acknowledge the "loss of precision"
(theoretically speaking).
-- Tony Morris http://xdweb.net/~dibblego/
- Next message: AlexKay: "Re: Hibernate alternatives"
- Previous message: Andrew Thompson: "Re: Executable JAR"
- In reply to: Mike Schilling: "Re: Can I force precision loss?"
- Next in thread: Yu SONG: "Re: Can I force precision loss?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|