We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi all,
Having trouble with the nfc function when using processing.js.
I'd expect the following to print 2.44 but instead prints 02
void setup() {
float chips = 2.4355677;
String chipsy = nfc(chips,2);
println(chipsy);
}
void draw() {
}
Any ideas?
Will
Answers
There are 4 number formatting styles in Processing:
They're overloaded to format integers w/ 2 parameters and fractions w/ 3 parameters.
All but nfc(), which expects 1 parameter only for integers and 2 for fractions.
Apparently, the PJS folks got that confused in v1.4.1! Converter nfc() still uses the general # of parameters like the other 3! @-)
Even though it's fixed in latest v1.4.7, that 1 isn't available in JS Mode yet! Much less on PJS code hosting sites! :o3
Therefore, when 1 or 2 parameters are passed in JS Mode, it guesses it's supposed to be integer rather than fraction formatting!
Passing 3 parameters would fix the PJS side, but wouldn't compile in Java mode! :-<
Thanks so much, this is fantastically useful
I only need it to work in PJS so BONUS!