Pages: [1]   Go Down
Author Topic: substring from right  (Read 163 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

    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 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
int temperature = sensors.getTempC(deviceAddress) * 100;
     String test(temperature);
     String test2 = test.substring(-2);
     String devcount(sensors.getDeviceCount(), DEC);


Offline Offline
Edison Member
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Pages: [1]   Go Up
Jump to: