delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/02/18:04:04

From: kevinx AT tst DOT hk DOT super DOT net (Mr Kevin Yeung)
Newsgroups: comp.lang.c,comp.os.msdos.djgpp
Subject: Re: DJGPP failed library tests?
Followup-To: comp.lang.c,comp.os.msdos.djgpp
Date: 2 Nov 1997 16:35:16 GMT
Organization: Hong Kong Supernet
Lines: 35
Distribution: world
Message-ID: <63ia44$hoo$1@tst.hk.super.net>
References: <639vjh$dru$1 AT tst DOT hk DOT super DOT net> <tgmEIyM5w DOT Mz AT netcom DOT com> <63hrdf$mpt$1 AT tst DOT hk DOT super DOT net>
NNTP-Posting-Host: is1.hk.super.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi guys,

Sorry to follow up myself. I just found out if I hardcode the numbers in
the assertion there won't be any failure. However, the following piece of
code certainly failed:

#include <assert.h>
#include <float.h>
#include <math.h>
#include <stdio.h>
#include <string.h>

int main()
{
  char buf[32];
  double db;
  float fl;
  long double ld;

  assert(sprintf(buf, "%E|%.2f|%Lg", 1.1e20, -3.346, .02L) == 23);
  assert(strcmp(buf, "1.100000E+20|-3.35|0.02") == 0);
  assert(sscanf(buf, "%e|%lg|%Lf", &fl, &db, &ld) == 3);
  assert(fabs(fl - 1.1e20) / 1.1e20 < 4 * FLT_EPSILON);
  assert(fabs(db + 3.35) / 3.35 < 4 * DBL_EPSILON);
  assert(fabs(ld - 0.02) / 0.02 < 4 * LDBL_EPSILON);
  return(0);
}

It seems to be the problem of the string functions rather than that of the
math functions. But the maths functions don't trap EDOM errors is for
sure.

--
Kevin Yeung
Change x to y in email address for private correspondence

- Raw text -


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