🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #25252

Re: Bet nobody else has *this* problem...

#25252
From: bill davidsen
Date: Thu, 15 Jan 1998 00:00
45 lines
2124 bytes
In article <wwvbtxedeia.fsf@sfere.greenend.org.uk>,
 <rjk@greenend.org.uk> wrote:
| matija@arnes.si (Matija Grabnar) writes:
| 
| > That's weird. Perl uses doubles by default, which means it is accurate
| > up to 49 bits, which should be enough even for most news applications:
| > 
| > perl -e '$j=1;for $i (0..64) { print "$i $j\n"; $j*=2; }'
| > 0 1
| [...]
| > 64 1.84467440737096e+19
| > 
| > Maybe someone said 'use int' or something like that?
| 
| I have been bitten by using `printf "%d"' with very large integers in
| Perl before...

The book says it used dp float, and obviously if you convert to int
you lose something (ie. print with %d). Try %.0f for this stuff.
Your little test program seems to work okay using that.

Ex:
 perl -e '$j=1;for $i (0..64) { printf "%d %.0f\n", $i, $j; $j*=2; }'

I would rather scale: (flames about source code to /dev/null)
================
# scale values

@suffix = (" ", "K", "M", "G", "T");
$val = $ARGV[0];
print "Val: $val  ";

for ($i = 0; $val >= 1000; ) { ++$i; $val /= 1024 }
printf "%5.1f%s\n", $val, $suffix[$i];
================

my general purpose print an unknown value route.
--
bill davidsen (davidsen@tmr.com)
  "The action you see on fishing programs is something like the women
in _Playboy_. Not actually *fake*, but not remotely typical of the
average person's experience."  -me

Technical Details
Message-ID: <69jjql$18dq$1@newssvr03-int.news.prodigy.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <34bc54cf.289908102@news.corp.home.net> <34bd3a1b.348629872@news.corp.home.net> <69im0p$bmu$1@kanja.arnes.si> <wwvbtxedeia.fsf@sfere.greenend.org.uk>

Show Full Headers
Complete Article Headers
Message-ID: <69jjql$18dq$1@newssvr03-int.news.prodigy.com>
Subject: Re: Bet nobody else has *this* problem...
Date: Thu, 15 Jan 1998 00:00:00 +0000
From: davidsen@tmr.com (bill davidsen)
References: <34bc54cf.289908102@news.corp.home.net> <34bd3a1b.348629872@news.corp.home.net> <69im0p$bmu$1@kanja.arnes.si> <wwvbtxedeia.fsf@sfere.greenend.org.uk>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 316014915
Organization: TMR Associates, Schenectady NY
Newsgroups: news.software.nntp
Originator: davidsen@darkstar.prodigy.com