Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Mike Amling Newsgroups: comp.lang.java.programmer Subject: Re: double-to-int conversion without a cast Date: Thu, 25 Feb 2016 12:37:46 -0600 Organization: A noiseless patient Spider Lines: 25 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 25 Feb 2016 18:34:10 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="20a2c13056a0f1c39c92bf91ba98023d"; logging-data="8838"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19wyJt6isgsHkMnyDQbIYfa" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: Cancel-Lock: sha1:0r+f76WksuD52MF8DiwyYEevfAY= Xref: csiph.com comp.lang.java.programmer:33883 On 2/24/16 7:07 PM, Stefan Ram wrote: > At a point in my course, I have only introduced basic > arithmetic operations and calls of static methods and > the types »int«, »double«, and »java.lang.String«. > > I already can show them how to convert from int to double > (»* 1.0«) or between the numbers and »java.lang.String« > (calling conversion methods from the Java SE standard > library). > > But I am not aware of how to convert from double to int > with only the above means. The standard library is large. > Maybe there is a static method that takes a double and returns > it's floor or rounded value as an int and I am not aware of it? > > I don't need this. I just ask for curiosity. Have you looked at Double.intValue()? Granted, that brings in java.lang.Double. Mike Amling -- VGhpcyBpcyBvbmx5IGdvaW5nIHRvIGV4YWNlcmJhdGUgdGhlICJhbGwgZGF0YSBtdXN0IGJlIHN0 b3JlZCBhcyBTdHJpbmciIG1lbWUu