{"id":17967298,"url":"https://github.com/microsoft/same-ish","last_synced_at":"2025-04-04T20:13:47.046Z","repository":{"id":42507039,"uuid":"107535312","full_name":"microsoft/same-ish","owner":"microsoft","description":"A Clojure library for approximate comparison of floating point types","archived":false,"fork":false,"pushed_at":"2025-02-12T19:03:35.000Z","size":453,"stargazers_count":41,"open_issues_count":1,"forks_count":11,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-28T19:10:05.073Z","etag":null,"topics":["clojure","clojurescript","floating-point","rounding-error","testing"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microsoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-19T11:04:29.000Z","updated_at":"2025-03-02T00:33:24.000Z","dependencies_parsed_at":"2025-02-28T22:27:37.704Z","dependency_job_id":"e35c2d5e-a2ca-4a6c-a8c1-47f3fe93de23","html_url":"https://github.com/microsoft/same-ish","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fsame-ish","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fsame-ish/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fsame-ish/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fsame-ish/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microsoft","download_url":"https://codeload.github.com/microsoft/same-ish/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247242680,"owners_count":20907134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","clojurescript","floating-point","rounding-error","testing"],"created_at":"2024-10-29T14:05:25.347Z","updated_at":"2025-04-04T20:13:47.027Z","avatar_url":"https://github.com/microsoft.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# same/ish - floating point comparisons for tests.\n\n\u003e Equality may perhaps be a right, but no power on earth can ever turn it into a fact.\\\n\u003e \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; — *Honore de Balzac*\n\n[![cljdoc](https://cljdoc.org/badge/same/ish)](https://cljdoc.org/d/same/ish)\n[![Build status](https://github.com/microsoft/same-ish/actions/workflows/build.yml/badge.svg?branch=main\u0026event=push)](https://github.com/microsoft/same-ish/actions/workflows/build.yml)\n[![Coverage](https://coveralls.io/repos/github/microsoft/same-ish/badge.svg?branch=main)](https://coveralls.io/github/microsoft/same-ish?branch=main)\n[![Downloads](https://img.shields.io/clojars/dt/same/ish.svg)](https://clojars.org/same/ish)\n\nYou have some functions that return doubles or floats and you want to write some tests.\nHow do you compare your results to the expected values?\nYou can't use equality because of rounding errors,\nso you have to check if the values are *near* each other.\nBut how near is near enough?\nAnd what if your numbers are buried inside data structures?\n\n`same/ish` is designed to help with these situations.\n\n## Usage\n\nSee the full API docs are available on [cljdoc](https://cljdoc.org/d/same/ish) for more detailed instructions and examples.\nA brief summary is provided below.\n\nIn Leiningen, add the following to your `:dependencies` in `project.clj`:\n\n[![Clojars Project](https://clojars.org/same/ish/latest-version.svg)](https://clojars.org/same/ish)\n\nThen in your test namespace(s), require `same.core`:\n```clojure\n(ns foo-test\n  (:requre [clojure.test :refer :all]\n           [same.core :refer [ish? zeroish?]]))\n```\n\nTo compare two numbers, instead of using `=` or `==`, use `ish?`:\n\n```clojure\n(defn f [x]\n  (* (/ 1. x) x)))\n\n(deftest f-test\n  (is (ish? 1.0 (f 49.0))))\n```\n\nYou can also compare data structures, and they will be compared element-wise, using `ish?`\nfor floating point types, `==` for other numbers, and `=` for anything else:\n\n```clojure\n(defn g [x]\n  {:a x\n   :b [(* x x) (Math/sqrt x)]))\n\n(deftest g-test\n  (is (ish? {:a 23 :b [529 4.7958315233]}\n            (g 23.0))))\n```\n\n## Requirements\n\nClojure 1.7.0 or higher is required due to the reader conditionals\nrequired for ClojureScript support.\n\n## References\n\n- [Comparing Floating Point Numbers, 2012 Edition](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/)\n- [What Every Computer Scientist Should Know About Floating-Point Arithmetic](https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html)\n- [Floating Point Demystified, Part 1](http://blog.reverberate.org/2014/09/what-every-computer-programmer-should.html)\n- [Floating Point Demystified, Part 2](https://blog.reverberate.org/2016/02/06/floating-point-demystified-part2.html)\n\n## Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md).\n\n## Contributing\n\nContributions are welcomed, see [CONTRIBUTING.md](CONTRIBUTING.md) for details.\n\n## License\n\nCopyright © Microsoft Corporation. All rights reserved.\\\nLicensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fsame-ish","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrosoft%2Fsame-ish","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fsame-ish/lists"}