PDA

View Full Version : Programming Help


JM^3
16-03-2006, 08:02:46
Hmm... I have problems again

Is there any good way to change double to int?

I guess my other concerns are probably inherent to ROOT http://root.cern.ch/root/html/src/TString.cxx.html#TString:Strip

JM

JM^3
16-03-2006, 08:06:34
http://root.cern.ch/root/html/TTree.html#TTree:Draw

current problem relates to this, I think

JM

Asher
16-03-2006, 08:09:41
double to int?

Can't you just round it? Or using ceil/floor...

JM^3
16-03-2006, 08:14:24
floor/ceil still have double as output...

JM
(at least, that is what I read)

JM^3
16-03-2006, 08:14:56
I am pretty sure that it si the problem with Draw that is crashing my program though

JM

Asher
16-03-2006, 08:16:26
Did you try typecasting it?

eg...

double penetration;

int awesome = (int)penetration;

Asher
16-03-2006, 08:17:35
In C++ I think the behavior when doing a double->int typecast is a floor, by the way.

JM^3
16-03-2006, 08:43:02
hmm, I have

double penetration;

int awesome = penetration;

JM

Asher
16-03-2006, 08:47:13
Add the (int) part

Nav
16-03-2006, 09:07:24
Originally posted by JM^3
hmm, I have

double penetration;
Nice, was it fun!?

Venom
16-03-2006, 14:23:38
It's been too long since I've done C++. I don't know if it would work, but wouldn't the easiest way be to just set the double equal to an int type variable? Or does that error in C++?

I don't remember. It's been 7 years since I used C++.

King_Ghidra
16-03-2006, 14:25:19
Originally posted by Nav
Nice, was it fun!?

Originally posted by JM^3
awesome = penetration

mr.G
16-03-2006, 18:55:26
thanks phill, i would have missed that.