Re: [go-nuts] Working with Floating-Point numbers

2018-02-12 Thread Michael Jones
Do you have particular questions? The overall situation is that floating
point arithmetic is good, but not like real numbers or symbolic algebra; it
is its own world and respecting the details is important (NaNs,
representability, tolerance in comparison, etc.)

On Mon, Feb 12, 2018 at 10:24 AM, Ian Lance Taylor  wrote:

> On Mon, Feb 12, 2018 at 9:40 AM, go-question
>  wrote:
> >
> > When working with Floating-point values in Go, what considerations need
> to
> > be made?
> >
> > The same for any other language?
> >
> > The Spec says that "Floating-point values are comparable and ordered"
> > https://golang.org/ref/spec#Comparison_operators
> >
> > So is comparing by some epsilon value not needed? or only for computed
> > values?
> > http://www.cygnus-software.com/papers/comparingfloats/
> Comparing%20floating%20point%20numbers.htm
> >
> > What is recommended (without external packages) when multiplying or
> adding
> > Floating-point values?
> > I know that internally those operations can be imprecise.
> > https://github.com/shopspring/decimal#faq
> > http://floating-point-gui.de/basic/
>
> This classic paper applies to Go just as much as it does to other
> programming languages:
>
> https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
>
> Ian
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Michael T. Jones
michael.jo...@gmail.com

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Working with Floating-Point numbers

2018-02-12 Thread Ian Lance Taylor
On Mon, Feb 12, 2018 at 9:40 AM, go-question
 wrote:
>
> When working with Floating-point values in Go, what considerations need to
> be made?
>
> The same for any other language?
>
> The Spec says that "Floating-point values are comparable and ordered"
> https://golang.org/ref/spec#Comparison_operators
>
> So is comparing by some epsilon value not needed? or only for computed
> values?
> http://www.cygnus-software.com/papers/comparingfloats/Comparing%20floating%20point%20numbers.htm
>
> What is recommended (without external packages) when multiplying or adding
> Floating-point values?
> I know that internally those operations can be imprecise.
> https://github.com/shopspring/decimal#faq
> http://floating-point-gui.de/basic/

This classic paper applies to Go just as much as it does to other
programming languages:

https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Working with Floating-Point numbers

2018-02-12 Thread Peter Weinberger
I would say it's the same as most languages. Go implements IEEE floating
point, so any comparison with a NaN is false.

On Mon, Feb 12, 2018 at 12:40 PM, go-question 
wrote:

> When working with Floating-point values in Go, what considerations need to
> be made?
>
> The same for any other language?
>
> The Spec says that "Floating-point values are comparable and ordered"
> https://golang.org/ref/spec#Comparison_operators
>
> So is comparing by some epsilon value not needed? or only for computed
> values?
> http://www.cygnus-software.com/papers/comparingfloats/
> Comparing%20floating%20point%20numbers.htm
>
> What is recommended (without external packages) when multiplying or adding
> Floating-point values?
> I know that internally those operations can be imprecise.
> https://github.com/shopspring/decimal#faq
> http://floating-point-gui.de/basic/
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Working with Floating-Point numbers

2018-02-12 Thread go-question
When working with Floating-point values in Go, what considerations need to 
be made?

The same for any other language?

The Spec says that "Floating-point values are comparable and ordered"
https://golang.org/ref/spec#Comparison_operators

So is comparing by some epsilon value not needed? or only for computed 
values?
http://www.cygnus-software.com/papers/comparingfloats/Comparing%20floating%20point%20numbers.htm

What is recommended (without external packages) when multiplying or adding 
Floating-point values? 
I know that internally those operations can be imprecise.
https://github.com/shopspring/decimal#faq
http://floating-point-gui.de/basic/

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.