Skip to content

Commit

Permalink
NumberParser_1.0.8.5 branch creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
varocarbas committed Oct 19, 2017
1 parent 0dc5bd6 commit e019e5a
Show file tree
Hide file tree
Showing 130 changed files with 124 additions and 21,958 deletions.
10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

File renamed without changes.
138 changes: 124 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,137 @@
# FlexibleParser (Java)
# NumberParser (Java)

[![Build Status](https://travis-ci.org/varocarbas/FlexibleParser_Java.svg?branch=master)](https://travis-ci.org/varocarbas/FlexibleParser_Java)
[Test program](https://github.com/varocarbas/FlexibleParser_Java/blob/master/all_code/Test/src/Parts/NumberParser.java)

**NOTE:** this is the conversion to Java of the original C# code stored in the [FlexibleParser repository](https://github.com/varocarbas/FlexibleParser).
[https://customsolvers.com/number_parser_java/](https://customsolvers.com/number_parser_java/) (ES: [https://customsolvers.com/number_parser_java_es/](https://customsolvers.com/number_parser_java_es/))

FlexibleParser is a multi-purpose parsing library based upon the following ideas:
## Introduction

- Intuitive, adaptable and easy to use.
- Pragmatic, but aiming for the maximum accuracy and correctness.
- Overall compatible and easily automatable.
- Formed by independent JARs managing specific situations.
The ```NumberParser``` package provides a common framework to deal with all the Java numeric types. It relies on the following four classes (NumberX):
- ```Number``` only supports the ```double``` type.
- ```NumberD``` can support any numeric type via ```Object```.
- ```NumberO``` can support different numeric types simultaneously.
- ```NumberP``` can parse numbers from strings.

## Parts
```Java
//1.23 (double).
Number number = new Number(1.23);

At the moment, FlexibleParser is formed by the following independent parts:
//123 (int).
NumberD numberD = new NumberD(123);

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1025468.svg)](https://zenodo.org/record/1025468) [UnitParser](https://customsolvers.com/unit_parser_java/) ([last release](https://github.com/varocarbas/FlexibleParser_Java/releases/tag/UnitParser_1.0.9.1), [readme file](https://github.com/varocarbas/FlexibleParser_Java/blob/master/all_readme/UnitParser_Java.md), [test program](https://github.com/varocarbas/FlexibleParser_Java/blob/master/all_code/Test/src/Parts/UnitParser.java))<br/>
It allows to easily deal with a wide variety of situations involving units of measurement.
Among its most salient features are: user-defined exception triggering and gracefully managing numeric values of any size.
//1.23 (double). Others: 1 (int) and '' (char).
NumberO numberO = new NumberO
(
1.23, new ArrayList()
{{
add(NumericTypes.Integer);
add(NumericTypes.Character);
}}
);

//1 (long).
NumberP numberP = new NumberP
(
"1.23", new ParseConfig(NumericTypes.Long)
);
```

## Authorship & Copyright
## Common Features

All the NumberX classes have various characteristics in common.
- Defined according to ```getValue()``` (```double``` or ```Object```) and ```getBaseTenExponent()``` (```int```). All of them support ranges beyond [-1, 1] * 10^2147483647.
- Static (```NumberD.Addition(numberD1, numberD2)```) and non-static (```numberD1.greaterThan(numberD2)```) support for the main arithmetic and comparison operations.
- Errors managed internally and no exceptions thrown.
- Numerous instantiating alternatives.

```Java
//12.3*10^456 (double).
Number number = new Number(12.3, 456);

//123 (int).
NumberD numberD =
(
new NumberD(123).lessThan(new NumberD(new Number(456))) ?
//123 (int)
new NumberD(123.456, NumericTypes.Integer) :
//123.456 (double)
new NumberD(123.456)
);


//Error (ErrorTypesNumber.InvalidOperation) provoked when dividing by zero.
NumberO numberO = NumberO.Division
(
new NumberO
(
123.0, OtherTypes.IntegerTypes
)
, new NumberO(0)
);

//1.234000000000e+308*10^5373 (double).
NumberP numberP = new NumberP("1234e5678");
```

## Math2 Class

This class includes all the NumberParser mathematical functionalities.

### Custom Functionalities

- ```RoundExact```/```TruncateExact``` can deal with multiple rounding/truncating scenarios not supported by the native methods.
- ```GetPolynomialFit```/```ApplyPolynomialFit``` allow to deal with second degree polynomial fits.
- ```Factorial``` calculates the factorial of any integer number up to 100000.

```Java
//123000 (double).
Number number = Math2.RoundExact
(
new Number(123456.789), 3, RoundType.AlwaysToZero,
RoundSeparator.BeforeDecimalSeparator
);

//30 (double).
NumberD numberD = Math2.ApplyPolynomialFit
(
Math2.GetPolynomialFit
(
new NumberD[]
{
new NumberD(1), new NumberD(2), new NumberD(4)
},
new NumberD[]
{
new NumberD(10), new NumberD(20), new NumberD(40)
}
)
, new NumberD(3)
);

//3628800 (int).
NumberD numberD = Math2.Factorial(new NumberD(10));
```

### Native Methods
```Math2``` also includes ```NumberD```-adapted versions of a big number of ```Math``` and .NET ```System.Math``` methods.

It also includes ```PowDecimal```\\```SqrtDecimal``` which allow to unrestrictedly use NumberX variables with ```Math.pow```\\```Math.sqrt```. Note that this Java version doesn't rely on the original C# custom implementation (detailed explanations in [varocarbas.com Project 10](https://varocarbas.com/fractional_exponentiation/)) because of only making sense within the .NET conditions (i.e., high-precision ```decimal``` type not natively supported by the in-built methods).

```Java
//1.582502898380e+14 (double).
Number number = Math2.PowDecimal
(
new Number(123.45), 6.789101112131415161718
);

//4.8158362157911885 (double).
NumberD numberD = Math2.Log(new NumberD(123.45));
```

## Further Code Samples
The [test application](https://github.com/varocarbas/FlexibleParser/blob/master/all_code/Test/Parts/NumberParser.cs) includes a relevant number of descriptive code samples.

## Authorship & Copyright
I, Alvaro Carballo Garcia (varocarbas), am the sole author of each single bit of this code.

Equivalently to what happens with all my other online contributions, this code can be considered public domain. For more information about my copyright/authorship attribution ideas, visit the corresponding pages of my sites:
Expand Down
Binary file removed all_binaries/UnitParser.jar
Binary file not shown.
Binary file removed all_binaries/UnitParser_without_javadoc.jar
Binary file not shown.
6 changes: 0 additions & 6 deletions all_code/Test/.classpath

This file was deleted.

17 changes: 0 additions & 17 deletions all_code/Test/.project

This file was deleted.

2 changes: 0 additions & 2 deletions all_code/Test/.settings/org.eclipse.core.resources.prefs

This file was deleted.

12 changes: 0 additions & 12 deletions all_code/Test/.settings/org.eclipse.jdt.core.prefs

This file was deleted.

This file was deleted.

51 changes: 0 additions & 51 deletions all_code/Test/build.xml

This file was deleted.

13 changes: 0 additions & 13 deletions all_code/Test/src/Main.java

This file was deleted.

Loading

0 comments on commit e019e5a

Please sign in to comment.