delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/09/30/00:07:31

From: "Guillermo Ballester Valor" <gbv AT ctv DOT es>
Newsgroups: comp.os.msdos.djgpp
Subject: HELP: What's wrong ?
Date: 29 Sep 1996 22:16:05 GMT
Organization: C.T.V.
Lines: 43
Message-ID: <01bbae54$12da4180$LocalHost@10.0.1.1.inf>
NNTP-Posting-Host: ctv4137.ctv.es
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hello:
I downloaded DJGPP V2 last week. I think is a superb C/C++ compilator. I
have been working in BORLAND C++ 4.52 before, and DJGPP is better in many
tasks.
I have re-compiled a lot of code writen in BORLAND IDE and I have no
serious problem to run it in DJGPP/DOS. That's my compiler ! :-)) 
There is only a problem. I cannot find the solution. When I use 'ldexp' 
function, defined in math.h, program breaks. On the contrary Borland
compiler works well. I don't know what's wrong. Below,  I have inserted a
simple p.cpp which produces a runtime error. I have observed that it always
appears in fifth call to ldexp, whatever be the arguments.

Machine: PC-clone Intel 486DX2 66 Mhz. Vesa Local bus 12 Mbytes RAM
OS : Ms-Dos 6.22 or WIN95/Dos-7
Compiler Invoke: gxx -g -o p.exe p.cpp -lm

PROGRAM : P.CPP 

/* This is a simple program test for ldexp function */
#include <math.h>
#include <stdio.h>
void test(double d, int n)
{
	double d1=ldexp(d,n);
	printf("\nldexp(%lf , %i ) is %lf",d,n,d1);
}

main()
{
	test(1,1);
	test(1,32);
	test(4,16);
	test(16,32);
	test(32,32);
	test(2.5,7);// and so on ... Always breaks in fifth call
}
	
I would like to know if I am doing something incorrect. Please help me.

**********************
G. Ballester
E-mail: gbv AT ctv DOT es
********************** 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019