Giter Club home page Giter Club logo

chash's People

Contributors

bitdeli-chef avatar bronsa avatar michaelklishin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

chash's Issues

Trying to do long arith with larger-than-long values

This code in clojurewerkz.chash.ring:

(def ^{:const true :tag long}
ring-top (dec (Math/pow 2 160)))

(defn ^long ring-increment
[^long n](quot ring-top n))

The first problem is that ^long before the name ring-increment does not make a function return a primitive long. It just puts useless metadata on the var and the function returns Object. That might be a bug in Clojure, I'm not sure.

The way to declare a primitive return type is to put the ^long type hint just before the vector of args. However, if you do that, then the compiler correctly throws an exception that ring-top is a double, not a long. Looking at the code, you try to put a long :tag on ring-top, but that cannot work, because the value is way too big to fit in a long.

I am not sure what the correct code should be, but probably something where ring-top is calculated using BigInteger methods would be better, then converting the result to bigint. Then perhaps move the return type hint for ring-increment, and coerce the bigint return value of quot to long using (long (quot ring-top n))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.