Code Monkey home page Code Monkey logo

Comments (3)

julien-boudry avatar julien-boudry commented on July 17, 2024

https://stackoverflow.com/questions/211345/working-with-large-numbers-in-php

php > var_dump($a = 12033222880 * 12033222880);                                                                                                                                                                                                
float(1.447984528797555E+20)
php > var_dump((int) $a);                                                                                                                                                                                                                      
int(-2775499709920919552)

from condorcet.

julien-boudry avatar julien-boudry commented on July 17, 2024

The following solutions are possible:

  1. Use this new dependency https://github.com/brick/math and use BigInt
    a. Pros: Does the job. Use BCMath PHP extension if available or in pure PHP. Should work with actual PHAR builder (Github action)
    b. Cons: First necessary external PHP library. __CondorcetAutoload.php installation method will not work anymore.

  2. Same as above, but with a Condorcet fallback with limitations (detect it an throw exception)

  3. Use directly BCMaths PHP extension
    a. Pros: Does the job.
    b. Cons: Extension not often available by default

  4. Same idea that 2. but with BCMaths instead brick/math

  5. Just detect the PHP limitation (check if int is becoming a float, or then a negative number, before returning it) and throw Exception. This will have no concrete voting method impacts, but the class Permutations and Combination will be limited which is a pity on the abstract side.
    a. Pros: No impact
    b. Cons: Not elegant

from condorcet.

julien-boudry avatar julien-boudry commented on July 17, 2024

Solution 2 ==> Merged

from condorcet.

Related Issues (20)

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.