It was pointed out to me that the precise issue came up before in the
libraries list in January 2011 as well:
http://www.haskell.org/pipermail/libraries/2011-January/015761.html
From the archives; it appears that proposal didn't generate much discussion
either. I think everyone is agreed on the
Hello all,
I definitely do not want to create a yet another thread on handling of
floating-point values in Haskell. My intention is only to see what can be
done to make it more compilant with IEEE754. (Also, my interest is not a
theoretical one, but rather entirely practical: I'm interested in
On 8/04/2013, at 11:21 AM, Levent Erkok wrote:
It appears that the consensus is that this is a historical definition dating
back to the times when IEEE754 itself wasn't quite clear on the topic itself,
and so nobody thought that hard about negative zeroes. (The quote is from a
comment from
#7198: New codegen more than doubles compile time of T3294
-+--
Reporter: simonmar | Owner: simonmar
Type: bug | Status: new
Priority: high
Andy Gimblett schrieb:
Hi Christian,
[...]
It may make sense to use something like readMaybe (which is missing in
the Prelude) instead of read to allow the parser to fail more nicely.
It seems to be kicking up reasonable errors as it is, e.g.:
*Main parse aFloat 2e-h
Left (line 1,
real :: Parser String
real = do
d - decimal
f - option $ do
p - char '.'
n - many1 digit
return $ p : n
Just to throw two bits in here, this is the only style that doesn't
require leaning on the space bar and squinting to line things up,
doesn't require any fancy editor
Hi Christian,
On 24 Feb 2010, at 13:24, Christian Maeder wrote:
I hope you don't mind if I make some style comments to your final
version.
Not at all - thanks!
1. break the line after do
(to avoid a layout change when change name or arguments of float' or
rename the variable e)
I'm not
Andy Gimblett wrote:
1. break the line after do
(to avoid a layout change when change name or arguments of float' or
rename the variable e)
I'm not convinced by this; perhaps while editing the code it's useful,
but those changes don't happen very often, and when they do, any
half-decent
Andy Gimblett schrieb:
For the record, here's the final improved version:
Hi Andy,
I hope you don't mind if I make some style comments to your final version.
1. break the line after do
(to avoid a layout change when change name or arguments of float' or
rename the variable e)
2. The t ::
On Wed, Feb 24, 2010 at 1:24 PM, Christian Maeder
christian.mae...@dfki.de wrote:
1. break the line after do
(to avoid a layout change when change name or arguments of float' or
rename the variable e)
You can also break it immediately before do, which I think is
sometimes more clear.
Ben Millwood schrieb:
On Wed, Feb 24, 2010 at 1:24 PM, Christian Maeder
christian.mae...@dfki.de wrote:
1. break the line after do
(to avoid a layout change when change name or arguments of float' or
rename the variable e)
You can also break it immediately before do, which I think is
-with-quickcheck/
That is, each syntactic category gets a pretty-printer and a parser
and an Arbitrary instance, and QuickCheck checks that (parse .
prettyPrint) == id, basically. Somewhat unsurprisingly, this
sometimes fails for floating point values (I'm using Doubles).
Now, I know
point values (I'm using Doubles).
Now, I know that floats are in some sense imprecise, and comparing for
equality is fraught with peril, but it seems that if x==x then it
ought to be at least _possible_ to arrange matters such that (parse .
prettyPrint x) == x as well. At worst, pretty
category gets a pretty-printer and a parser and
an Arbitrary instance, and QuickCheck checks that (parse . prettyPrint)
== id, basically. Somewhat unsurprisingly, this sometimes fails for
floating point values (I'm using Doubles).
Now, I know that floats are in some sense imprecise, and comparing
Short version: How can I pretty print and parse values of type Double
such that those operations are each other's inverse?
Maybe you have more luck with show and read (without Parsec.Token).
Your example:
x = 9.91165677454629
fails because the computation performed by the parser
9.0 +
gets a pretty-printer and a parser and an
Arbitrary instance, and QuickCheck checks that (parse . prettyPrint) == id,
basically. Somewhat unsurprisingly, this sometimes fails for floating point
values (I'm using Doubles).
Now, I know that floats are in some sense imprecise, and comparing
For the record, here's the final improved version:
float' :: TokenParser st - GenParser Char st Double
float' t = do n - liftCtoS '-'
w - many1 digit
char '.'
f - many1 digit
e - option $ do char 'e'
n' -
Dear all
I have what I think should be a relatively simple problem:
I have a C program which reads in data from a binary file, it is a
specific format so it knows that there are 3 integers followed by three
doubles or whatever. So I'm trying to serialise the data from within a
Haskell program
On Jan 9, 2008 5:18 AM, allan [EMAIL PROTECTED] wrote:
Essentially then, is there anyone that can write my 'putDouble' function
or give some hint as to how I might do it.
For the moment assume that I'm not really concerned with portability
across platforms at least for the time being (I
#1239: compare on exceptional Doubles and Floats should raise an error
+---
Reporter: igloo | Owner:
Type: proposal| Status: closed
Priority: normal
#1239: compare on exceptional Doubles and Floats should raise an error
---+
Reporter: igloo | Owner:
Type: proposal| Status: new
Priority: normal
Bayley, Alistair wrote:
I've built a small test case. When I compile with:
ghc Main.hs test.c -o Main.exe
... the (correct) output from Main.exe is:
123.0
5678901234567890
And when I compile with:
ghc -prof Main.hs test.c -o Main.exe
... the (incorrect) output from Main.exe is:
1.0
986516178
I
On 15 September 2004 00:33, Roberto Zunino wrote:
However, compiling with
ghc -prof Main.hs test.c -#include test.h
or s/-prof/-fvia-C/, works fine, provided test.h contains the correct
function prototypes.
-- test.h
long long myInt64(void);
double myDouble(void);
--
I've built a small test case. When I compile with:
ghc Main.hs test.c -o Main.exe
... the (correct) output from Main.exe is:
123.0
5678901234567890
And when I compile with:
ghc -prof Main.hs test.c -o Main.exe
... the (incorrect) output from Main.exe is:
1.0
986516178
-- Main.hs:
{-#
(using GHC 6.2.1 under Windows XP)
I'm trying to use the Sqlite (version 3) dll - see http://www.sqlite.org/ .
Marshalling of 32-bit ints and Strings works well, but 64-bit Ints and
Doubles fail (I get garbage back from the FF calls) when I compile with
-prof -auto-all. If I compile without
--- Bayley, Alistair
[EMAIL PROTECTED] wrote:
(using GHC 6.2.1 under Windows XP)
I'm trying to use the Sqlite (version 3) dll - see
http://www.sqlite.org/ .
Hi Alistair,
HSQL already provides binding to sqlite. I don't know
whether you will have the same problem with profiling
version of
, just
to make sure the problem isn't with the Sqlite dll.
-Original Message-
From: Krasimir Angelov [mailto:[EMAIL PROTECTED]
Sent: 13 September 2004 10:53
To: Bayley, Alistair; [EMAIL PROTECTED]
Subject: Re: Profiling makes FFI Marshalling of Doubles and
Int64s fail
--- Bayley
--- Bayley, Alistair
[EMAIL PROTECTED] wrote:
Thanks Krasimir. I did have a look at your code, but
I don't see any foreign
types other than CString and Int, which work OK for
me regardless of
profiling option. (BTW, you tend to use Int rather
than CInt - is this
safe?)
Good suggestion.
: 13 September 2004 12:28
To: Bayley, Alistair; [EMAIL PROTECTED]
Subject: RE: Profiling makes FFI Marshalling of Doubles and
Int64s fail
--- Bayley, Alistair
[EMAIL PROTECTED] wrote:
Thanks Krasimir. I did have a look at your code, but
I don't see any foreign
types other than
Quick and probably stupid question:
If I want to convert a Float to a Double, should I use
fromRational . toRational
? It seems to work, but isn't this a bit weird? It took a while for
me to figure this out. I suppose they are rationals because of the
finite precision of Floats and Doubles
to figure this out. I suppose they are rationals because of the
finite precision of Floats and Doubles? And similarly, (fromInteger
. toInteger) is the right way to convert the integral types?
Why not just have a function like:
convertIntegral :: (Integral a, Integral b) = a - b
W licie z sob, 08-11-2003, godz. 22:41, Ben Escoto pisze:
If I want to convert a Float to a Double, should I use
fromRational . toRational
realToFrac :: (Fractional b, Real a) = a - b
It is actually defined as fromRational . toRational but GHC knows to
generate specialized code for
W licie z sob, 08-11-2003, godz. 22:59, Hal Daume III pisze:
In NumExts, there's floatToDouble and doubleToFloat.
It's a GHC extension, while realToFrac is Haskell 98.
--
__( Marcin Kowalczyk
\__/ [EMAIL PROTECTED]
^^ http://qrnik.knm.org.pl/~qrczak/
On Sun, 09 Nov 2003 01:11:09 +0100
Marcin 'Qrczak' Kowalczyk [EMAIL PROTECTED] wrote:
realToFrac :: (Fractional b, Real a) = a - b
It is actually defined as fromRational . toRational but GHC knows to
generate specialized code for particular types.
Oops, I was looking through the prelude but
Juan Ignacio Garcia Garcia wrote:
*P2 (fromRational ((toRational 4) - ( toRational 5.2 )))
-1.2002
I can't explain this one, how would fromRational
know that it has to create a Double ?
Jan
___
Glasgow-haskell-users mailing list
[EMAIL
On Wed, 13 Nov 2002, Jan Kort wrote:
Juan Ignacio Garcia Garcia wrote:
*P2 (fromRational ((toRational 4) - ( toRational 5.2 )))
-1.2002
I can't explain this one, how would fromRational
know that it has to create a Double ?
It's the defaulting mechanism that kicks in. The
But this brings up a strange thing in GHCi. Suppose I load
the following module into GHCi:
\begin{code}
module Foo where
kalle = (fromRational ((toRational 4) - ( toRational 5.2 )))
default (Rational)
\end{code}
What happens is the following:
Prelude :l Foo.hs
Compiling Foo
hello,
I have been using some of the functions of the classes Real and
Fractional and I have observed that with the funcion toRational we can
obtain the fraction that represents a given number. For instance:
*P2 toRational (5.2::Float)
5452595 % 1048576
Why we obtain this numbers instead of 52 %
I have been using some of the functions of the classes Real and
Fractional and I have observed that with the funcion
toRational we can
obtain the fraction that represents a given number. For instance:
*P2 toRational (5.2::Float)
5452595 % 1048576
Why we obtain this numbers instead of 52
Yes, they all seem to be right.
You get these funny effects because numbers like 5.2 do not have an
exact representation with floating point numbers in base to (like Float
and Double most likely have on your machine). The number 5.2 is stored
as a slightly different number as a Float, but the
Lennart Augustsson wrote:
The number 5.2 is stored
as a slightly different number as a Float, but the toRational function
is exact
so it gives you the number corresponding to the internal representation.
Take a course on numerical analysis. :)
Nope. Take a course entitled:
Why all you
| -Original Message-
| From: Jan Skibinski [mailto:[EMAIL PROTECTED]]
| Sent: Thursday, August 10, 2000 3:11 PM
| To: [EMAIL PROTECTED]
| Cc: [EMAIL PROTECTED]
| Subject: Re: doubles
|
|
|
|
| Aha . And how many digits will GHC offer me?
|
| I would think that you will get
Hi!
How can I use Doubles which are more exact than six digits?
For example HUGS gives me :
1,23456789
1.23457
I want to rotate coordinates with eulerian matrizes and I'm using the pi
from the Prelude ( 6 digits).
After about 1000 360°-rotations I have an error of about 0.1% ; but I
want
On Thu, 10 Aug 2000, Sebastian Schulz wrote:
Hi!
How can I use Doubles which are more exact than six digits?
For example HUGS gives me :
1,23456789
1.23457
1. What you see printed and what is used in internal
computations are two different things.
2
Or you can just set USE_DOUBLE_PRECISION in options.h if you want to
rebuild hugs.
John
Jan Skibinski wrote:
1. What you see printed and what is used in internal
computations are two different things.
In HUGS I can see 6 digits. How many are used in the intrnal
computation?
2. But Hugs'es Double is the same as Float, anyway.
This used to
Aha . And how many digits will GHC offer me?
I would think that you will get the same number of digits
as is available for C - unless some bits are reserved
for something special, which I am not aware of.
For example, in some implementations of Smalltalk the
Sebastian Schulz [EMAIL PROTECTED] writes:
John Peterson wrote:
Or you can just set USE_DOUBLE_PRECISION in options.h if you want to
I did that (to be precise, I had to do it every time when building
hugs :-( ).
pi::Double is defined by the prelude as primPiDouble, and this
seems to be
Is there a means of formatting doubles in Haskell with the precision
flexibilty of printf? The show method seems to only print the first
few decimal places, and showGFloat in the numeric module seems to only
display a similar number
For example, in hugs...
import Numeric
x
It seems, as if I have the questionable pleasure of
reporting the first bug in GHC 4.08: The NCG passes floats
as doubles in foreign exports.
If the appended code is compiled with the NCG (ie, without
optimisation), the programs prints 0.0 instead of 101.0. If
the C code is changed to use
rigid and I belong to the small legion of amateurs who implemented their
own math. domain system, Rings, Fields, Modules, etc. This apparently
has no chance to be included into the Haskell standard, nobody cares.
Standards develop because people who care about particular aspects
of them push
51 matches
Mail list logo