# TString

**URL:** <https://root-forum.cern.ch/t/tstring/1186>\
**Category:** ROOT\
**Created:** [October 20, 2004, 6:55am UTC](https://root-forum.cern.ch/t/tstring/1186 "2004-10-20T06:55:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kbat](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/8dc957/32.png) [@kbat](https://root-forum.cern.ch/u/kbat)\
**Post date:** [October 20, 2004, 6:55am UTC](https://root-forum.cern.ch/t/tstring/1186/1 "2004-10-20T06:55:15Z")

</div>

Hi,  
Does anyone know how to remove these spaces between “=” and “2.75” produced by the following code?

```auto
root [0] TString str("x=")   
root [1] str += 2.75         
(class TString)"x= 2.75"
root [2] cout << str << endl;
x= 2.75
```

---

<div class="post-metadata">

**Author:** ![brun](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/b9e5f3/32.png) [@brun](https://root-forum.cern.ch/u/brun)\
**Post date:** [October 20, 2004, 7:11am UTC](https://root-forum.cern.ch/t/tstring/1186/2 "2004-10-20T07:11:27Z")

</div>

To circumvent this problem, do  
TString str(Form(“x=%f”,2.75));

Rene

---

<div class="post-metadata">

**Author:** ![kbat](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/8dc957/32.png) [@kbat](https://root-forum.cern.ch/u/kbat)\
**Post date:** [October 20, 2004, 7:58am UTC](https://root-forum.cern.ch/t/tstring/1186/3 "2004-10-20T07:58:59Z")

</div>

Thank you Rene, but there is another problem:

```auto
root [0] Float_t x = 2.75;
root [1] TString str(Form("x=%.2f", x));
root [2] cout << str << endl;
x=0.00
```

But I’m expecting to get “x=2.75”. Why does it give me zero?

---

<div class="post-metadata">

**Author:** ![brun](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/b9e5f3/32.png) [@brun](https://root-forum.cern.ch/u/brun)\
**Post date:** [October 20, 2004, 8:12am UTC](https://root-forum.cern.ch/t/tstring/1186/4 "2004-10-20T08:12:40Z")

</div>

Use Double\_t instead of Float\_t.  
A Form (in the interpreter) accepts int, double, char\*

Rene
