long long behaves unexpectedly...

From: Kazuya AOKI <aoki_at_nh.scphys.kyoto-u.ac.jp>
Date: Fri, 25 Feb 2005 06:32:03 +0900


Dear ROOT exprets,

I have trouble with long long.
I tried to execute the following script

///// source --------------------------------------

void test(void){

   for(int i=0; i<10; i++){

     long long data;
     data=43000LL;      //  <----- !!!! here !!!!
     cout << i << " : " << data << endl;
   }

   return;
}


the results are the following

///// result -----------------------------------------------

root [0] .x test.C

0 : 43000
1 : 167797363
2 : 167797363
3 : 167797363
4 : 167797363
5 : 167797363
6 : 167797363
7 : 167797363
8 : 167797363
9 : 167797363

root [1]

but what i expect is, of course, the following.

///// ( expected )result -----------------------------------------------

root [0] .x test.C

0 : 43000
1 : 43000
2 : 43000
3 : 43000
4 : 43000
5 : 43000
6 : 43000
7 : 43000
8 : 43000
9 : 43000

root [1]

when I compiled the source with g++ ,
I got the expected results.

Could you give me some advice?

the following is the ROOT version i use.

////// version

[fukao_at_rcas2077 ~]$ root


FreeType Engine v2.1.3 used to render TrueType fonts. Compiled for linux with thread support.

CINT/ROOT C/C++ Interpreter version 5.15.152, Sep 13 2004 Type ? for help. Commands must be C++ statements. Enclose multiple statements between { }. root [0]

Best Regards,
Kazuya Received on Thu Feb 24 2005 - 22:32:17 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:05 MET