Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #2564 > unrolled thread
| Started by | Soroush Heidari <soroush.heidari@gmail.com> |
|---|---|
| First post | 2011-05-21 10:48 +0000 |
| Last post | 2011-05-22 10:59 +0000 |
| Articles | 2 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
Problem with MLGetReal(Double) in Mathlink Soroush Heidari <soroush.heidari@gmail.com> - 2011-05-21 10:48 +0000
Re: Problem with MLGetReal(Double) in Mathlink Soroush Heidari <soroush.heidari@gmail.com> - 2011-05-22 10:59 +0000
| From | Soroush Heidari <soroush.heidari@gmail.com> |
|---|---|
| Date | 2011-05-21 10:48 +0000 |
| Subject | Problem with MLGetReal(Double) in Mathlink |
| Message-ID | <ir8594$bfj$1@smc.vnet.net> |
When I change the simple addtwo program in order to get 2 Real
(Double) numbers and get a Real result, the result is wrong (5+4 =
97986213 !) What is the problem.
Thanks...
***********************************************************************
#include <stdio.h>
#include "mathlink.h"
int main( int argc, char* argv[])
{
double a, b;
double ans;
MLINK lp;
MLEnvironment env;
printf( "Enter two integers: a and b\n\t" );
scanf( "%d %d", &a, &b);
env = MLInitialize(NULL);
if(env == NULL) return 1;
lp = MLOpen(argc, argv);
if(lp == NULL) return 1;
MLPutFunction(lp, "Plus", 2);
MLPutDouble(lp, a);
MLPutDouble(lp, b);
MLEndPacket(lp);
/* skip any packets before the first ReturnPacket */
while (MLNextPacket(lp) != RETURNPKT) MLNewPacket(lp);
MLGetDouble(lp, &ans);
printf( "ans = %d\n", ans);
MLClose(lp);
MLDeinitialize(env);
return 0;
}
[toc] | [next] | [standalone]
| From | Soroush Heidari <soroush.heidari@gmail.com> |
|---|---|
| Date | 2011-05-22 10:59 +0000 |
| Message-ID | <iraq9u$lt7$1@smc.vnet.net> |
| In reply to | #2564 |
Have anyone tried to work with double variables in MathLink...!?
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web