Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.
double txtlong;
double Flong;
txtlong= -91.9472
Flong= -91.92250
double longdistance;
longdistance=Flong-txtlong; <----- this line does not give the correct answer.
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
#include <iostream>
using namespace std;
int main()
{
double txtlong;
double Flong;
txtlong= -91.9472;
Flong= -91.92250;
double longdistance;
longdistance=Flong-txtlong;
cout << longdistance << endl;
}
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double txtlong;
double Flong;
Flong= -91.92;
txtlong= -91.95;
double longdistance;
// -91.92 +91.95
longdistance= Flong - txtlong;
cout << longdistance << endl;
cout << std::abs(Flong - txtlong) << endl;
cout << Flong - txtlong << endl;
cout << txtlong - Flong << endl;
}
int main()
{
double txtlong;
double Flong;
txtlong= -91.9472;
Flong= -91.92250;
double longdistance;
longdistance=Flong-txtlong;
// here I set a breakpoint
return 0;
}
Following is my c++ and vb 6.0 code
// example1.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include <iostream.h>
#include <math.h>
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
double _stdcall sum(double x , double y, double m, double n, double i)
{
double latdistance;
double longdistance;
double txtlong;
double txtlat;
double Flong;
double Flat;
double comparelong;
double comparelat;
double N_S_distance;
double E_W_distance;
double iValue;
double rValue;
Flat=x;
txtlong= n;
Flong = y;
txtlat=m;
iValue=i;
latdistance=Flat-txtlat;
longdistance=Flong-txtlong;
if (longdistance < 0.00)
{comparelong=-1.00;}
if (longdistance>0.00)
{comparelong=1.00;}
if (latdistance<0.00)
{comparelat=-1.00;}
if (latdistance>0.00)
{comparelat=1.00;}
N_S_distance=comparelong*acos(cos(((90-txtlat)*3.14159265)/180)*cos(((90-txtlat)*3.14159265)/180)+sin(((90-txtlat)*3.14159265)/180)*sin(((90-txtlat)*3.14159265)/180)*cos(((txtlong-Flong)*3.14159265)/180))*3440.65;
E_W_distance=comparelat*acos(cos(((90-txtlat)*3.14159265)/180)*cos(((90-Flat)*3.14159265)/180)+sin(((90-txtlat)*3.14159265)/180)*sin(((90-Flat)*3.14159265)/180)*cos(((Flong-Flong)*3.14159265)/180))*3440.65;
if (iValue==1.0)
{ rValue=latdistance;}
if(iValue==2.0)
{rValue=longdistance;}
if(iValue==3.0)
{rValue=N_S_distance;}
if(iValue==4.0)
{rValue=E_W_distance;}
return rValue;
}
-----------------------------------------------------------------------------------------------
Private Declare Function sum Lib "example1.dll" (ByVal x As Double, ByVal y As Double, ByVal m As Double, ByVal n As Double, ByVal p As Double) As Double
Private Sub Command1_Click()
Dim x, y, m, n, q
x = CDbl("29.890280")
m = CDbl("-91.92250")
y = CDbl("-91.9472")
n = CDbl("28.0")
q = CDbl("2.0")
Text3.Text = sum(x, y, m, n, q)
End Sub
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.