Try:
TString::Atof(), like:
root [0] TObjString s("0.0000034177")
root [1] s.String().Atof()
(const Double_t)3.41769999999999991e-06
root [2]
But in case you read your data from file I would use:
sscanf("%f %f ...", ...)
to get the numbers out in a more efficient way.
Cheers, Fons.
On 22/11/2011 14:02, Andreas Adelmann wrote:
> Hello I try to uses the Tokenizer on a TString
>
> char line(CHRLEN);
>
> .....
>
> TString s(line);
> TObjArray *d = s.Tokenize(TString(" "));
>
> s contains floats (0.000034177 0.000074050 0.000136709 0.000233544
> 0.000267721) with a spaces as delimiter.
>
> d->Print() shows me that all my number are no in TObjString, as expected.
>
> Collection name='TObjArray', class='TObjArray', size=128
> TObjString = 0.000034177
> ......
>
> Now my plan was to use the Sting() function of TObjString and finally
> convert them into Double_t in order to add the values to a histogram.
>
> However I could not fin out how to convert d[i] -> TObjString or even
> better d[i] -> Double_t.
>
> Thanks for the help, Andreas
> ------
> Dr. sc. math. Andreas (Andy) Adelmann
> Staff Scientist
> Paul Scherrer Institut WLGB/132 CH-5232 Villigen PSI
> Phone Office: xx41 56 310 42 33 Fax: xx41 56 310 31 91
> Phone Home: xx41 62 891 91 44
> -------------------------------------------------------
> Thursdays: ETH CAB H 83.1 +41 44 632 36 72
> ============================================
> The more exotic, the more abstract the knowledge,
> the more profound will be its consequences.
> Leon Lederman
> ============================================
>
>
>
-- Org: CERN, European Laboratory for Particle Physics. Mail: 1211 Geneve 23, Switzerland E-Mail: Fons.Rademakers_at_cern.ch Phone: +41 22 7679248 WWW: http://fons.rademakers.org Fax: +41 22 7669640Received on Tue Nov 22 2011 - 14:18:52 CET
- application/pkcs7-signature attachment: S/MIME Cryptographic Signature
This archive was generated by hypermail 2.2.0 : Tue Nov 22 2011 - 17:50:01 CET