Each year, only about 2 out of my 30 students are natural programmers. I will do anything to make the coding easier to understand so that my class becomes a problem solving class instead of a typing class. I am fairly fast at finding the things that the students will have problems with.
Most of the Particle community members will be natural programmers (or really hard workers) so I would expect little interest in these issues.
I have to teach String(x, DEC); as different from String(x, HEX) so why not teach String(X, DEC, 2); as formatting to 2 decimal places.
You and I have no problem with
sprintf(data, "x=%.2f", x);
but 28 or my 30 kids will have a problem with it. I agree that any changes to the Particle code base will have growing pains. If Particle does not think it is worth the developmental costs, then that is fine with me.
...
...
Here is the Particle code
void setup() {
float y = 0.000;
int x = 3456;
y = x/100;
Particle.publish("y =",String(y), 60, PRIVATE);
}
Output: y = 34.000000
Here is PHP code
<?php
$y = 0.00;
$x = 3456;
$y = $x/100;
echo "y= $y ";
?>
Output: y= 34.56
And here is a javascript version:
<input type=button value=divide onclick="{
y = 0.00
x = 3456
y = x/100
alert(y)
}">
Alert box output: 34.56
I can live with this issue as just something the students need to know about C++, but it does seem a bit strange. The fix is fairly easy.
void setup() {
float y = 0.000;
int x = 3456;
y = x/100.0;
Particle.publish("y =",String(y), 60, PRIVATE);
}
Output: y =34.560001
Got to love the sneaky "1" at the 6th decimal place