Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

jlong to long !

843829Aug 5 2002 — edited Aug 5 2002
Hi ;

What casting should I do to jlong inorder to get a proper long representing the same number .
running the next example gives the below resault :

int main()
{
jlong f = 40956436157 ;
unsigned long g = (unsigned long)f ; // my jlongs will always be positive values
cout <<"testing ="<<g<<endl;
return 1 ;
}

resault :
testing =2301730493

(I tried first with simple long casting and I got : -1993236803 )
I understand that the problem must be with the number of bits representing the long type in c++ , but are there any ideas ?

Thanks ;
Adaya .

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 2 2002
Added on Aug 5 2002
3 comments
504 views