Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #2564

Problem with MLGetReal(Double) in Mathlink

From Soroush Heidari <soroush.heidari@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Problem with MLGetReal(Double) in Mathlink
Date 2011-05-21 10:48 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <ir8594$bfj$1@smc.vnet.net> (permalink)

Show all headers | View raw


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;
}

Back to comp.soft-sys.math.mathematica | Previous | NextNext in thread | Find similar | Unroll thread


Thread

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

csiph-web