Code Monkey home page Code Monkey logo

deveel-math's Introduction

Build status NuGet MyGet NuGet MyGet Pre Release Join the chat at https://gitter.im/deveel/deveel-math

Deveel Math

This is the port of the Java Math library implemented by the Apache Harmony framework, that is used to factorize big numbers and decimals, for the .NET and Mono frameworks. In fact the native .NET support for decimal numbers appear to be limited in several contexts, leading some independent developments of the support within applications.

Tha aim of this library is to provide .NET developers with a powerful instrument to handle operations on very big numbers, keeping performances and reliability under control.

How to Install It

The library is maintained in two separate repositories from where it is possible to install it: in fact, the nightly builds can be found at the dedicated space of MyGet, while the production packages can be found at nuget.org From the NuGet Package Management console, select the project where the library will be installed and type the following command

PM> Install-Package dmath

If you are developing a .NET Standard or .NET Core application, you can install the dmath.core library instead

PM> Install-Package dmath.core

deveel-math's People

Contributors

gitter-badger avatar tsutomi 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  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

deveel-math's Issues

Exception trying to divide BigDecimal by a number

Hi,
I was testing your lib and faced with exception: Non-terminating decimal expansion; no exact representable decimal result.

I was trying to do the following:

BigDecimal bigDecimal = BigDecimal.Parse("45465464646546546464646446547777777777777777777777777777888888888888888888888888888888777777777778542222222222221333333335");
         bigDecimal /= 700;
         MessageBox.Show(bigDecimal);

I expect thta it must return decimal result as a string, but it throws an exception instead.

Could this be fixed?

Library is broken

Assert.AreEqual(16, 
               BigDecimal.Parse("9999,9999,9999,9999".Replace(",", ""))
                           .StripTrailingZeros().Precision);

It fails, with the actual value being 17 ... Yikes! Something to do with StripTrailingZeros ...

I've also seen issues with unnecessary rounding, when Parsing strings with a MathContext with a precision of 16, and where there's only been 16 digits. Probably negative numbers, cause I've seen negative numbers created using a big integer constructor, with a Precision of 17 when there's clearly only 16 digits, and that when you Abs() the value the Precision is 16.

I'm using <package id="dmath" version="1.5.66" targetFramework="net45" />

I feel like this package needs a lot more testing? I don't really have the time at the moment.

Support of the PCL Model

Develop and deploy a version of Deveel Math library for the Portable Class Library profile (for mobile systems)

Not enough precision for BigDecimal

Hi. Found another issue.

The following code:

BigDecimal bigDecimal = new BigDecimal(1000);
bigDecimal += 0.0005;

Will give result 1000.1, which is not what I expect.
Could this be workaround somehow or maybe I am missing something?

And another issue:

BigDecimal bigDecimal = new BigDecimal(1000.0005);

Will give me
image

Why not 1000.0005 exactly?

Non-terminating decimal expansion

I tried to calculate this:
BigDecimal.Parse("-3.8272") / BigDecimal.Parse("-4.448")
which resulted to the following exception.
Non-terminating decimal expansion; no exact representable decimal result.

Is there no support for this type of calculation, I mean dividing two negative rational numbers?

Thx

UPDATE:
I figured it out. However I am not really satisfied with it.
The / operator does not use a context with a precision and rounding method, so the explicit Divide method should be used. Which is however not trivial without any kind of documentation. And could be addressed by using a default context with a standard precision. Because in this case the / operator is really just misleading, since the program can throw exceptions at random places.

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.