Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #26513

Re: Possible loss of precision

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.albasani.net!.POSTED!not-for-mail
From Michael Jung <miju@golem.phantasia.org>
Newsgroups comp.lang.java.programmer
Subject Re: Possible loss of precision
Date Fri, 15 Nov 2013 19:24:47 +0100
Organization albasani.net
Lines 18
Message-ID <87txfded5c.fsf@golem.phantasia.org> (permalink)
References <loss-20131113231933@ram.dialup.fu-berlin.de> <87txfe22o1.fsf@golem.phantasia.org> <kkla89tv4vb3c60ao7qkj2hr3kd0ims4gc@4ax.com>
Mime-Version 1.0
Content-Type text/plain; charset=iso-8859-1
Content-Transfer-Encoding 8bit
X-Trace news.albasani.net uMSMcNlM43IKVstp8PjVFz+AmcYnQYMorZhS8AQIsg1plReU3IIP1ZjSohmYPRqEg8n30VKfuDqs7oNFPJOecg==
NNTP-Posting-Date Fri, 15 Nov 2013 18:24:48 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="V++yFAIAh/RosDkghmK43UL2GfA0kpFLknv0UYa3/dyCypIkTUAkdrQAUq09qX7WXZxrx6u31xwgJTtcmdRLWwagxhffFaeiUw2+aPRoJMTvvEwjI3BuDGPPgdDOkcF+"; mail-complaints-to="abuse@albasani.net"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock sha1:qpY2E0fD+gJ8rSNMd96fF6ZoLao= sha1:RnIhgBoaBcrP2U1NqEHH8Q8rI1U=
Xref csiph.com comp.lang.java.programmer:26513

Show key headers only | View raw


Gene Wirchenko <genew@telus.net> writes:
> On Thu, 14 Nov 2013 20:39:42 +0100, Michael Jung
> <miju@golem.phantasia.org> wrote:
>>ram@zedat.fu-berlin.de (Stefan Ram) writes:
[...]
>>>   But then, »int i = 2.0;« gives an error, even though the
>>>   compiler should see that »2.0« can be represented as an int.
>>You are right that x+1 is "promoted" to int and the second assignment
>>fails.  In the other cases the compiler will follow JLS 15.28 => 5.2.
>>This concerns constant expressions first and the second allows a
>>narrowing in rare cases, of which the first line is one but the
>>"int i = 2.0" isn't.
>      Why isn't it though?

Since compile-time constant expressions are FP-strict and could be done,
I guess it was seen as pathological and not worth the effort.

Michael

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Possible loss of precision Michael Jung <miju@golem.phantasia.org> - 2013-11-14 20:39 +0100
  Re: Possible loss of precision Gene Wirchenko <genew@telus.net> - 2013-11-14 15:03 -0800
    Re: Possible loss of precision Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-11-14 18:31 -0500
      Re: Possible loss of precision Joerg Meier <joergmmeier@arcor.de> - 2013-11-15 00:55 +0100
      Re: Possible loss of precision Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-11-14 20:19 -0500
        Re: Possible loss of precision taqmcg@gmail.com - 2013-11-15 07:01 -0800
        Re: Possible loss of precision Martin Gregorie <martin@address-in-sig.invalid> - 2013-11-15 21:36 +0000
    Re: Possible loss of precision Michael Jung <miju@golem.phantasia.org> - 2013-11-15 19:24 +0100
      Re: Possible loss of precision Patricia Shanahan <pats@acm.org> - 2013-11-15 20:48 -0800
        Re: Possible loss of precision Michael Jung <miju@golem.phantasia.org> - 2013-11-17 13:28 +0100
          Re: Possible loss of precision Patricia Shanahan <pats@acm.org> - 2013-11-17 08:05 -0800

csiph-web