Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2003
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: MathLink: support for long longs?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg44109] Re: [mg43889] MathLink: support for long longs?
  • From: Dale <dale at omegaconsultinggroup.com>
  • Date: Thu, 23 Oct 2003 07:14:55 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

At 02:05 AM 10/10/2003, Sascha Kratky wrote:
>Hi,
>
>Many C compilers have a type "long long" for doing 64bit integer
>arithmetic. Does MathLink support sending and receiving of "long long"
>values?
>
>Thanks,
>Sascha

Not as a native type, but MathLink does have text interface which allows 
you to transfer generic data as strings. Here's an example adapted from 
FastBinaryFiles (http://library.wolfram.com/infocenter/MathSource/354/).

Putting data to Mathematica:

long long temp;
long numchars;
char buf[64];

sprintf(buf, "%lld", temp);
numchars = (long)strlen(buf);
MLPutNext(stdlink, MLTKINT);
MLPutSize(stdlink, numchars);
MLPutData(stdlink, buf, numchars);

Getting data from Mathematica:

long long temp;
long num_bytes;
int type;
char buf[64];

type = MLGetNext(stdlink);
MLBytesToGet(stdlink, &num_bytes);
MLGetData(stdlink, buf, num_bytes, &num_bytes);
buf[num_bytes] = '\0';
sscanf(buf, "%lld", &temp);

--------------------------------------------------------------
Omega Consulting
"The final answer to your Mathematica needs"
http://omegaconsultinggroup.com


  • Prev by Date: Re: two's complement function
  • Next by Date: Re: InterpolatingFunctionAnatomy
  • Previous by thread: MathLink: support for long longs?
  • Next by thread: Partial dérivates