user31185: I want to make a floating point number that has only one decimal point.
I have separate integers for both side.
Ex: 
int n1 = 8;
int n2 = 2;
I want to make 8.2 as float value using separate integers.
Please give me a solution.

user31105: float x = (float) n1 + (float) (n2 / 10.0);

This works only if the value of n2 has 1 digit. Otherwise the following make it smaller until n2 gets below 1.0:
float x = (float) n1;

float f2 = (float) n2;
while (f2 >= 1.0)
{
   f2 /= 10.0;
}
x = n1 + f2;


user7508: Seems too simple:
float x = n1 + n2 * 0.1;

Is there a trick?
Edit: The method proposed by Michel Keijzers, namely
float x = n1 + n2 / 10.0;

(I removed the redundant casts) can be slightly more accurate, but takes
longer to compute, because division is significantly slower than
multiplication on the Uno. Computing n2/10.0 always yields the
correctly rounded result, namely the float that best approximates the
exact mathematical result. On the other hand, n2*0.1 involves two
rounding operations: one at compile time, in the representation of 0.1
(which is not an exact float), another at run time, which rounds the
result of the multiplication. If n2 is between 0 and 8, you end up
getting the correctly rounded result anyway, just as with n2/10.0.
However, if n2 is 9, then

n2*0.1 yields 0.900000035762786865234375 (error ≈ 3.6e-8)
n2/10.0 yields 0.89999997615814208984375 (error ≈ -2.4e-8)

The former carries a rounding error 1.5 larger than the latter.

31185: <p>I want to make a floating point number that has only one decimal point.
I have separate integers for both side.
Ex: </p>

<p><code>int n1 = 8;</code></p>

<p><code>int n2 = 2;</code></p>

<p>I want to make 8.2 as float value using separate integers.
Please give me a solution.</p>
 31105: <pre><code>float x = (float) n1 + (float) (n2 / 10.0);
</code></pre>

<p>This works only if the value of n2 has 1 digit. Otherwise the following make it smaller until n2 gets below 1.0:</p>

<pre><code>float x = (float) n1;

float f2 = (float) n2;
while (f2 &gt;= 1.0)
{
   f2 /= 10.0;
}
x = n1 + f2;
</code></pre>
 7508: <p>Seems too simple:</p>

<pre><code>float x = n1 + n2 * 0.1;
</code></pre>

<p>Is there a trick?</p>

<p><strong>Edit</strong>: The method proposed by Michel Keijzers, namely</p>

<pre><code>float x = n1 + n2 / 10.0;
</code></pre>

<p>(I removed the redundant casts) can be slightly more accurate, but takes
longer to compute, because division is significantly slower than
multiplication on the Uno. Computing <code>n2/10.0</code> always yields the
correctly rounded result, namely the float that best approximates the
exact mathematical result. On the other hand, <code>n2*0.1</code> involves <em>two</em>
rounding operations: one at compile time, in the representation of 0.1
(which is not an exact float), another at run time, which rounds the
result of the multiplication. If <code>n2</code> is between 0 and 8, you end up
getting the correctly rounded result anyway, just as with <code>n2/10.0</code>.
However, if <code>n2</code> is 9, then</p>

<ul>
<li><code>n2*0.1</code> yields 0.900000035762786865234375 (error ≈ 3.6e-8)</li>
<li><code>n2/10.0</code> yields 0.89999997615814208984375 (error ≈ -2.4e-8)</li>
</ul>

<p>The former carries a rounding error 1.5 larger than the latter.</p>
