delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/03/26/14:22:36

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-0.6 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_23,J_CHICKENPOX_71,J_CHICKENPOX_73,J_CHICKENPOX_75,SARE_MSGID_LONG40
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
In-Reply-To: <49CBB054.3020804@sbcglobal.net>
References: <75cc17ac0903260927ke99cb69t6e89a0d7b32f960b AT mail DOT gmail DOT com> <49CBB054 DOT 3020804 AT sbcglobal DOT net>
Date: Thu, 26 Mar 2009 14:22:17 -0500
Message-ID: <75cc17ac0903261222w5a0a70d8p92fd00bacb0d437e@mail.gmail.com>
Subject: Re: tokyo cabinet
From: Gregg Reynolds <dev AT mobileink DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Thu, Mar 26, 2009 at 11:41 AM, Greg Chicares <gchicares AT sbcglobal DOT net> wrote:
> On 2009-03-26 16:27Z, Gregg Reynolds wrote:
> [...]
>> #define strtold(a,b) ((long double)strtod((a),(b)))
>>
>> make check fails on
>>
>> tchtest write casket 50000 5000 5 5
>
> Does that test depend on accurate long-double i/o,
> which the strtod() kludge sacrifices?
>

It uses it, but I don't know if it actually needs the long double.  I
suppose it does, considering it's part of a test suite. ;)

Here's the code that uses strtold:

/* Convert a string with a metric prefix to an integer. */
int64_t tcatoix(const char *str){
  assert(str);
  char *end;
#define strtold(a,b) ((long double)strtod((a),(b))) /*gar*/
  long double val = strtold(str, &end);
  int inf = isinf(val);
  if(inf != 0) return inf > 0 ? INT64_MAX : INT64_MIN;
  if(!isnormal(val)) return 0;
  if(*end == 'k' || *end == 'K'){
    val *= 1LL << 10;
  } else if(*end == 'm' || *end == 'M'){
    val *= 1LL << 20;
  } else if(*end == 'g' || *end == 'G'){
    val *= 1LL << 30;
  } else if(*end == 't' || *end == 'T'){
    val *= 1LL << 40;
  } else if(*end == 'p' || *end == 'P'){
    val *= 1LL << 50;
  } else if(*end == 'e' || *end == 'E'){
    val *= 1LL << 60;
  }
  if(val > INT64_MAX) return INT64_MAX;
  if(val < INT64_MIN) return INT64_MIN;
  return val;
}

It looks to me like that should work, but then again it's been a while
since I dug into serious code.  I'm not even sure how isinf is
supposed to work.

Thanks,

gregg

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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