Pages: [1]   Go Down
Author Topic: substring from right  (Read 144 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

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

Thanks
Logged

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

dtostrf()

http://lmgtfy.com/?q=dtostrf+libc+arduino
Logged

Pages: [1]   Go Up
Jump to: