Go Down

Topic: substring from right (Read 348 times) previous topic - next topic


    have data that come from the 1-wire library, since i can't convert easily a float to a string, i multiply the float by 100 to a int and then convert it to a string, this seems to work good event with the minus. now i want to reconstruct the sting with the comma.so i will like to use the substring but from the right side since the length of the string is not always equal and the precision is set always to 2 number after the comma.
Here the code
Code: [Select]
int temperature = sensors.getTempC(deviceAddress) * 100;
     String test(temperature);
     String test2 = test.substring(-2);
     String devcount(sensors.getDeviceCount(), DEC);





Go Up