user30244: Hi I have a program that does not work right as I aspect:
v = tempC;
h = tempC * 10;
h = h % 10;
memset(stempCA, 0, sizeof(stempCA));
sprintf(stempCA, "%+.2d.%d", v, h);

it works fine on positive temperature "+11.22"
but not for negative values : "-02.-1"
where is my mistake?
 thanx

user15180: I think, that -1%10=-1, not 9 as you would like. I use 
if (tempC<0) {print'-';tempC=-tempC;};
print tempC as usual for positive numbers


30244: <p>Hi I have a program that does not work right as I aspect:</p>

<pre><code>v = tempC;
h = tempC * 10;
h = h % 10;
memset(stempCA, 0, sizeof(stempCA));
sprintf(stempCA, "%+.2d.%d", v, h);
</code></pre>

<p>it works fine on positive temperature "+11.22"
but not for negative values : "-02.-1"</p>

<p>where is my mistake?
 thanx</p>
 15180: <p>I think, that -1%10=-1, not 9 as you would like. I use </p>

<pre><code>if (tempC&lt;0) {print'-';tempC=-tempC;};
print tempC as usual for positive numbers
</code></pre>
