If the computation doesn’t change observable value - then it’s the same value… 
(when use as a key/equality) - which is why a better detection of change might 
be on the “value added” - but if that isn’t stored, you’ll be back to same spot.

> On Feb 22, 2020, at 3:06 PM, 'simon place' via golang-nuts 
> <golang-nuts@googlegroups.com> wrote:
> 
> are you sure?
> 
> surely floats can have, say, a small number added, that depending of the 
> value, sometimes doesn't change them and sometimes does. seems to me the same 
> issue.
> 
> On Saturday, 22 February 2020 19:58:09 UTC, robert engels wrote:
> float equality is useful for determining if “something changed” (e.g. the 
> record has changed), you can also use float keys - the equality matters, the 
> actual value not so much.
> 
>> On Feb 22, 2020, at 1:50 PM, 'simon place' via golang-nuts 
>> <golan...@googlegroups.com <>> wrote:
>> 
>> absolutely, though even an epsilon is a bit of a hack IMHO. given the more 
>> ops you do the greater the potential discrepancy, and, i guess, you get a 
>> normal dist. of values, so any epsilon only has a probability of working, 
>> albeit potentially astronomically high probability.
>> 
>> so then why even have float equality in the/any language at all?
>> 
>> or might be nice if vet warned
>> 
>> On Sunday, 26 January 2020 03:34:11 UTC, Kurtis Rader wrote:
>> This is why you should never, ever, do a simple equality test involving a 
>> F.P. value derived from a calculation. You always have to apply an epsilon 
>> to define a range within which the two F.P. values should be considered 
>> equal.
>> On Sat, Jan 25, 2020 at 7:14 PM Jason E. Aten <j.e...@gmail.com <>> wrote:
>> 
>> https://play.golang.org/p/87bDubJxjHO <https://play.golang.org/p/87bDubJxjHO>
>> 
>> I'd like to truncate a float64 to just 2 decimal places (in base 10), but 
>> math.Trunc is not helping me here... ideally I put 0.29 in and I get 0.29 
>> out.
>> Suggestions?  Playground examples appreciated.
>> 
>> package main
>> 
>> import (
>>      "fmt"
>>      "math"
>> )
>> 
>> // truncate off everything after the last two decimals, no rounding.
>> func decimal2(x float64) float64 {
>>     return math.Trunc(x*100) / 100
>> }
>> 
>> func main() {
>>         x := 0.29
>>         y := decimal2(x)
>>      fmt.Printf("x=%v -> y = %v", x, y) // prints x=0.29  ->  y=0.28
>> }
>> 
>> -- 
>> 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 golan...@googlegroups.com <>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/96528d64-a670-45ba-ad4c-0701dcd0d78d%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/golang-nuts/96528d64-a670-45ba-ad4c-0701dcd0d78d%40googlegroups.com?utm_medium=email&utm_source=footer>.
>> 
>> 
>> -- 
>> Kurtis Rader
>> Caretaker of the exceptional canines Junior and Hank
>> 
>> -- 
>> 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 golan...@googlegroups.com <>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/229c73ce-88fb-46a0-a2ee-8454cbaa6ae5%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/golang-nuts/229c73ce-88fb-46a0-a2ee-8454cbaa6ae5%40googlegroups.com?utm_medium=email&utm_source=footer>.
> 
> 
> -- 
> 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 
> <mailto:golang-nuts+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/c37a2676-e6d2-4513-bb82-aad9b4755d80%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/golang-nuts/c37a2676-e6d2-4513-bb82-aad9b4755d80%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/283E5055-8AAB-4229-B0AE-73049BBA4D16%40ix.netcom.com.

Reply via email to