# Oddities with Particle.publish() and float

can someone explain why the String.toFloat() method is behaving oddly.

The string variable is always properly set, but If I have the number variable defined as float, it never gets set in the function, but if it is defined as double it does get set.

Also, I am getting none of the approximation (as described in the documentation) if I pass in 123.123 the double value becomes 123.1220004783746 something. Unless the decimal portion is a proper decimal (1/(power of 2))

``````double foo  = 100.0;
//float foo - 100.0;
String fooStr = "UNDEF";

void setup(void) {

Particle.variable("FooStr", fooStr);
Particle.variable("Foo", foo);
}

void loop(void)
{
delay(1000);
}

{
fooStr = command;
foo = fooStr.toFloat();
}``````

Not answering your question, but you should return an `int` since your function is declared as `int AdjustMyValue(String command);`

The trouble with floating point types is that you canâ€™t represent every real number due to the way how they are stored.
Although `float` and `double` are a bit more complex than this, the basic idea is that binary numeric types only store powers of 2.
e.g. 12.25 = â€¦ + 02^4 + 12^3 + 12^2 + 02^1 + 02^0 + 02^-1 + 12^-2 + 02^-3 + â€¦
but not all possible real numbers can be represented like this with a finite number of bits.

Update:
Iâ€™ve tried with `float`and the conversion works as expected (try with `Serial.print(foo, 5)`). Itâ€™s only `Particle.variable()` or the cloud side of the system seems to have problems with interpreting `float` as `double`.