<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Made in Software &#187; double</title>
	<atom:link href="http://www.madeinsoftware.it/index.php/tag/double/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.madeinsoftware.it</link>
	<description>In un mondo fatto di software, consigli pratici per gli sviluppatori</description>
	<lastBuildDate>Mon, 26 Jul 2010 09:17:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Arrotondare un double all&#8217;intero più vicino</title>
		<link>http://www.madeinsoftware.it/index.php/2009/05/20/arrotondare-un-double-allintero-piu-vicino/</link>
		<comments>http://www.madeinsoftware.it/index.php/2009/05/20/arrotondare-un-double-allintero-piu-vicino/#comments</comments>
		<pubDate>Wed, 20 May 2009 15:19:42 +0000</pubDate>
		<dc:creator>dinox</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[arrotondare]]></category>
		<category><![CDATA[double]]></category>
		<category><![CDATA[numeri]]></category>
		<category><![CDATA[precisione]]></category>

		<guid isPermaLink="false">http://www.madeinsoftware.it/?p=75</guid>
		<description><![CDATA[Come arrotondare in JAVA un double alla precisione desiderata o al numero intero più vicino]]></description>
			<content:encoded><![CDATA[<p>Se in JAVA dovete <strong>arrotondare un numero con la virgola all&#8217;intero più vicino</strong> o comunque ad un numero decimale ma con le cifre (la precisione) da noi decisa, potete utilizzare questa funzione:</p>
<p><code>/**<br />
* Arrotonda eventualmente un double all'intero più vicino&lt;BR&gt;<br />
* Esempi:&lt;BR&gt;<br />
* rounder(3.99, 1e-2) -&gt; 4.0<br />
* rounder(3.99, 1e-3) -&gt; 3.99<br />
* @param value valore da arrotondare<br />
* @param precision precisione; ad esempio, 1e-7 indica che vogliamo 7 cifre decimali max dopo la virgola<br />
* @return il valore eventualmente arrotondato<br />
*/<br />
public static double roundToInteger(double value, double precision) {<br />
if (value&gt;=0)<br />
return 1.0-(value-Math.floor(value)) &lt; precision ? Math.ceil(value) : value;<br />
else<br />
return 1.0-(Math.ceil(value)-value) &lt; precision ? Math.floor(value) : value;<br />
}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.madeinsoftware.it/index.php/2009/05/20/arrotondare-un-double-allintero-piu-vicino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
