"converting to long long int from double error.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class point{
      public :
             long long double x, y, z, xp, yp, zp;
             

             void modifypoint(long long double initial[][3],long long double 
                              rotate[][3], long long double a1, 
                              long long double b1, long long double c1, int i)
              {
              x = initial[i][0];    
              y = initial[i][1]; 
              z = initial[i][2]; 
                       
              xp =  x*cos(b1)*cos(c1) + y*cos(b1)*sin(c1) - z*sin(b1);  
              yp =  x*( sin(a1)*sin(b1)*cos(c1)-cos(a1)*sin(c1) )            
                    +y*( sin(a1)*sin(b1)*sin(c1)+cos(a1)*cos(c1) )            
                    +z*( sin(a1)*cos(b1) );                               
              zp =  x*( cos(a1)*sin(b1)*cos(c1)+sin(a1)*sin(c1) )       
                    + y*( cos(a1)*sin(b1)*sin(c1)-sin(a1)*cos(c1) )      
                    + z*( cos(a1)*cos(b1) );                                
                       
              rotate[i][0] = xp;
              rotate[i][1] = yp;                       
              rotate[i][2] = zp; 
                       
             
             } 

};


Before change all the 'double' into long long double, i get no error. But after the changes i get the error message, but i need the long long for precision. Is there any possible way to fix this error without sacrificing the precision?
Why do you need so much precision? Long long double is not a legal type, and might be recognised as a long long int by your compiler. Which version of compiler are you using? long double is a legal type.

http://gcc.gnu.org/ml/gcc-prs/2002-05/msg00313.html


What was the actual error text in full?

And what does the call to modifypoint look like?

On another front, the variables x, y, z, xp, yp, zp should be private IMO.
Last edited on
Opps sorry, the problems is from my carelessness, i didn't noticed i opened 2 main.cpp at a same time. I guess this was the cause of the problems. I want the program to calculate the coordinate precisely, during the process, it will pass many long decimal number, i just hope i can get a very precise number.

EDIT: Thanks anyways :D
Last edited on
A double gives 16 digits of precision, a long double might give 18, but depends on your compiler.

Why would you want more than 16?
wow 16!! so it can hold a value of 0.1234567890123456 ?
Well, that is 17 counting the first 0. Google setprecision to display values with cout.

There is also stuff in numeric_limits, such as min & max values - it's all in the reference section at the top left of this page.

HTH
Ok, thanks you.
Topic archived. No new replies allowed.