Skip to content

Instantly share code, notes, and snippets.

@nmcb
Created April 23, 2024 20:23
Show Gist options
  • Save nmcb/951e36ccc72af0efb5ef553da1fa5828 to your computer and use it in GitHub Desktop.
Save nmcb/951e36ccc72af0efb5ef553da1fa5828 to your computer and use it in GitHub Desktop.
double multiplication is not associative
$ amm
Loading...
Welcome to the Ammonite Repl 3.0.0-M1 (Scala 2.13.13 Java 17.0.10)

@ import org.scalacheck.Prop.forAll 
import org.scalacheck.Prop.forAll

@ val multiplicationIsAssociative = forAll { (a: Double, b: Double, c: Double) =>
    (a * b) * c == a * (b * c)
  } 
multiplicationIsAssociative: org.scalacheck.Prop = Prop

@ multiplicationIsAssociative.check() 
! Falsified after 0 passed tests.
> ARG_0: -4.913383864757722E-96
> ARG_1: -2.6018540342432862E64
> ARG_2: 2.1518855899862393E-277
> ARG_1_ORIGINAL: -7.491530883868791E227
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment