473,789 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Printing Floating-Point Numbers Quickly and Accurately"

Does anyone (Tim?) have (ideally Python, but I can cope) code
implementing the fixed-format algorithm from the Subject: named paper
by Burger & Dybvig?

Cheers,
mwh

--
<Erwin> #python FAQ: How do I build X? A: Wait for twisted.X.
-- from Twisted.Quotes
Jul 18 '05 #1
2 3148
[Michael Hudson]
Does anyone (Tim?) have (ideally Python, but I can cope) code
implementing the fixed-format algorithm from the Subject: named paper
by Burger & Dybvig?


I don't, and you're too young if you think anyone else might <wink>.

The paper gives Scheme code, you know! And there's a Haskell variant here:

http://lml.ls.fi.upm.es/~jjmoreno/ma...t/numeric.html

As the paper says at the end,

[David] Gay ... showed that floating-point arithmetic is sufficiently
accurate in most cases when the requested number of digits is small.
The fixed-format printing algorithm described in this paper is useful when
these heuristics fail.

IOW, the point of Burger & Dybvig was to run faster than the
algorithms in the earlier Steele & White paper, but David Gay's code
*usually* beats everything on speed (if you don't care about speed,
code for this task is quite simple; if you do care about speed, it's
mind-numbingly complicated), so there's little incentive to implement
this algorithm. Gay's code is written in C, & available from Netlib:

http://www.netlib.org/fp/
Jul 18 '05 #2
Tim Peters <ti********@gma il.com> writes:
[Michael Hudson]
Does anyone (Tim?) have (ideally Python, but I can cope) code
implementing the fixed-format algorithm from the Subject: named paper
by Burger & Dybvig?
I don't, and you're too young if you think anyone else might <wink>.

The paper gives Scheme code, you know!


Not for the fixed format algorithm it doesn't. The paper says:

The rational arithmetic used in fixed-format printing can wbe
converted into high-precision integer arithmetic by introducing a
common denominator as before. Because there are several more cases
to consider, however, the resulting code is lengthy and has
therefore been omitted from this paper.

I was hoping someone else had considered all the cases for me :-)

I've already translated the free format code from the paper into
Python, unfortunately it's not what I actually need...
And there's a Haskell variant here:

http://lml.ls.fi.upm.es/~jjmoreno/ma...t/numeric.html
That's the free format algorithm again, unless I've gone blind.
As the paper says at the end,

[David] Gay ... showed that floating-point arithmetic is sufficiently
accurate in most cases when the requested number of digits is small.
The fixed-format printing algorithm described in this paper is useful when
these heuristics fail.

IOW, the point of Burger & Dybvig was to run faster than the
algorithms in the earlier Steele & White paper, but David Gay's code
*usually* beats everything on speed (if you don't care about speed,
code for this task is quite simple; if you do care about speed, it's
mind-numbingly complicated), so there's little incentive to implement
this algorithm.
I'm probably suffering from an attack of perfectionism. Burger &
Dubvig's algorithm is so neat!
Gay's code is written in C, & available from Netlib:

http://www.netlib.org/fp/


Now *that* code is over-the-top, even for me :-)

Cheers,
mwh

--
. <- the point your article -> .
|------------------------- a long way ------------------------|
-- Christophe Rhodes, ucam.chat
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
2392
by: Geoff Cox | last post by:
Hello, I am trying to have 1. web pages in large font 2. web pages with smaller font for printing I am using <link rel="stylesheet" media="print" type="text/css"
0
1436
by: geoffhanna | last post by:
I am not referring to the standard PrintDialog. This dialog pops up every time my printdocument.printpage event fires. He only has one button - "Cancel" and contains no other controls I am printing multiple documents in a batch and this guy just flashes all over the place. It looks really bad but even worse, is significantly slowing performance I cannot find a setting anywhere that will suppress this dialog. Anyone?
0
1512
by: Harry Whitehouse | last post by:
I misposted this quesiton earlier in this newsgroup. The print dialog in my application (the one where you select a printer) can be centered on the parent form without much trouble. But can one control the position of the subsequent "Printing..." dialog which appears while the job is actually being spooled? I don't see anyway to access that dialog to center it (or to modify the text on it). Can it be done?
0
1197
by: Harry Whitehouse | last post by:
I can center the print dialog on my parent window just fine. But how can I control the location of the status window that pops up during the actual page printing? My app is programmed to center in the screen, and the printing status dialog appears up in the upper left corner of the screen (outside of the application). Is there any way to control this status window? TIA
4
1697
by: GD | last post by:
I have a collection of asp:LinkButtons on a web form. Based on some reporting criteria, I will be "highlighting" some of these LinkButtons. I'd like the user to be able to mouseover the LinkButton and get a "floating layer" with some text in this. How can I achieve this on the server side? The conditions that I will evaluate in order to determine whether or not to highlight a button will be evaluated on the server side.
9
3474
by: ewolfman | last post by:
Hi, I need to provide the user with the option to click something, and what follows is: 1. Download a word document, without displaying winword. 2. Printing the document to the default printer (no print dialog should pop). 3. Close word. All of this must be completely "transparent" to the user, just like a
25
11910
by: mdh | last post by:
I wrote a little insignificant program, to help me write a more significant one!!...that was supposed to print all Ascii values from 0 to 127: >>>> #include <stdio.h> # define UPPER_LIMT 127 int main (){
0
1330
by: Emby | last post by:
Hi, I am aware that the "Printing" dialog displayed by a PrintDocument during the invocation of the doc.Print method can be suppressed by setting the doc's PrintController property to an instance of StandardPrintController. But I would like to suppress the "Printing" dialog when the doc is rendered in a PrintPreviewControl - does anyone know how to accomplish this? Thanks, Emby
0
1509
by: Emby | last post by:
Hi, I am aware that the "Printing" dialog displayed by a PrintDocument during the invocation of the doc.Print method can be suppressed by setting the doc's PrintController property to an instance of StandardPrintController. But I would like to suppress the "Printing" dialog when the doc is rendered in a PrintPreviewControl - does anyone know how to do that? Thanks,
8
16569
n8kindt
by: n8kindt | last post by:
how do i suppress the outputting and printing dialog boxes that pop up while running vba code such as: DoCmd.OpenReport "Report1" or DoCmd.OutputTo acOutputReport, "Report1", acFormatPDF, Filename, False i tried a suggestion to use this code i found on another website: Option Compare Database Option Explicit
0
9663
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9016
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4090
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2906
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.