Giter Site home page Giter Site logo

Comments (2)

mishal avatar mishal commented on June 11, 2024

Which locale are you speaking about?

from iless.

tapetersen avatar tapetersen commented on June 11, 2024

I don't know the specifics with the different locale variables but in some countries (for example SWEDEN locale sv_SE) numbers are formatted using a comma "," as decimal point instead of a point ".". Php uses those settings when converting numbers to strings which means that for example during
Iless_UnitConversion::setup() on UnitConversion.php:66 Iless_Math::divide gets called with '2' and M_PI, which then gets converted to string as M_PI => "3,141592....". bcmul in turn doesn't respect the locale when parsing that string and treats it as 0 resulting in a divide by zero error.

The locale can be manipulated by http://www.php.net/manual/en/function.setlocale.php

For example:
$saved_locale = setlocale('LC_ALL', 0);
setlocale('LC_ALL', 'C');

// Do math stuff

setlocale('LC_ALL', $saved_locale);

would solve the problem.
Another option would be to do the float to string conversion explicitly with
http://www.php.net/manual/en/function.number-format.php
number_format(M_PI, 10, '.'. '')
instead of through a cast.

from iless.

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.