Skip to content

Commit e019e5a

Browse files
committed
NumberParser_1.0.8.5 branch creation.
1 parent 0dc5bd6 commit e019e5a

File tree

130 files changed

+124
-21958
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+124
-21958
lines changed

.travis.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

README.md

Lines changed: 124 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,137 @@
1-
# FlexibleParser (Java)
1+
# NumberParser (Java)
22

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

5-
**NOTE:** this is the conversion to Java of the original C# code stored in the [FlexibleParser repository](https://github.com/varocarbas/FlexibleParser).
5+
[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/))
66

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

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

14-
## Parts
15+
```Java
16+
//1.23 (double).
17+
Number number = new Number(1.23);
1518

16-
At the moment, FlexibleParser is formed by the following independent parts:
19+
//123 (int).
20+
NumberD numberD = new NumberD(123);
1721

18-
[![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/>
19-
It allows to easily deal with a wide variety of situations involving units of measurement.
20-
Among its most salient features are: user-defined exception triggering and gracefully managing numeric values of any size.
22+
//1.23 (double). Others: 1 (int) and '' (char).
23+
NumberO numberO = new NumberO
24+
(
25+
1.23, new ArrayList()
26+
{{
27+
add(NumericTypes.Integer);
28+
add(NumericTypes.Character);
29+
}}
30+
);
2131

32+
//1 (long).
33+
NumberP numberP = new NumberP
34+
(
35+
"1.23", new ParseConfig(NumericTypes.Long)
36+
);
37+
```
2238

23-
## Authorship & Copyright
39+
## Common Features
40+
41+
All the NumberX classes have various characteristics in common.
42+
- Defined according to ```getValue()``` (```double``` or ```Object```) and ```getBaseTenExponent()``` (```int```). All of them support ranges beyond [-1, 1] * 10^2147483647.
43+
- Static (```NumberD.Addition(numberD1, numberD2)```) and non-static (```numberD1.greaterThan(numberD2)```) support for the main arithmetic and comparison operations.
44+
- Errors managed internally and no exceptions thrown.
45+
- Numerous instantiating alternatives.
46+
47+
```Java
48+
//12.3*10^456 (double).
49+
Number number = new Number(12.3, 456);
50+
51+
//123 (int).
52+
NumberD numberD =
53+
(
54+
new NumberD(123).lessThan(new NumberD(new Number(456))) ?
55+
//123 (int)
56+
new NumberD(123.456, NumericTypes.Integer) :
57+
//123.456 (double)
58+
new NumberD(123.456)
59+
);
60+
61+
62+
//Error (ErrorTypesNumber.InvalidOperation) provoked when dividing by zero.
63+
NumberO numberO = NumberO.Division
64+
(
65+
new NumberO
66+
(
67+
123.0, OtherTypes.IntegerTypes
68+
)
69+
, new NumberO(0)
70+
);
71+
72+
//1.234000000000e+308*10^5373 (double).
73+
NumberP numberP = new NumberP("1234e5678");
74+
```
75+
76+
## Math2 Class
77+
78+
This class includes all the NumberParser mathematical functionalities.
79+
80+
### Custom Functionalities
2481

82+
- ```RoundExact```/```TruncateExact``` can deal with multiple rounding/truncating scenarios not supported by the native methods.
83+
- ```GetPolynomialFit```/```ApplyPolynomialFit``` allow to deal with second degree polynomial fits.
84+
- ```Factorial``` calculates the factorial of any integer number up to 100000.
85+
86+
```Java
87+
//123000 (double).
88+
Number number = Math2.RoundExact
89+
(
90+
new Number(123456.789), 3, RoundType.AlwaysToZero,
91+
RoundSeparator.BeforeDecimalSeparator
92+
);
93+
94+
//30 (double).
95+
NumberD numberD = Math2.ApplyPolynomialFit
96+
(
97+
Math2.GetPolynomialFit
98+
(
99+
new NumberD[]
100+
{
101+
new NumberD(1), new NumberD(2), new NumberD(4)
102+
},
103+
new NumberD[]
104+
{
105+
new NumberD(10), new NumberD(20), new NumberD(40)
106+
}
107+
)
108+
, new NumberD(3)
109+
);
110+
111+
//3628800 (int).
112+
NumberD numberD = Math2.Factorial(new NumberD(10));
113+
```
114+
115+
### Native Methods
116+
```Math2``` also includes ```NumberD```-adapted versions of a big number of ```Math``` and .NET ```System.Math``` methods.
117+
118+
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).
119+
120+
```Java
121+
//1.582502898380e+14 (double).
122+
Number number = Math2.PowDecimal
123+
(
124+
new Number(123.45), 6.789101112131415161718
125+
);
126+
127+
//4.8158362157911885 (double).
128+
NumberD numberD = Math2.Log(new NumberD(123.45));
129+
```
130+
131+
## Further Code Samples
132+
The [test application](https://github.com/varocarbas/FlexibleParser/blob/master/all_code/Test/Parts/NumberParser.cs) includes a relevant number of descriptive code samples.
133+
134+
## Authorship & Copyright
25135
I, Alvaro Carballo Garcia (varocarbas), am the sole author of each single bit of this code.
26136

27137
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:

all_binaries/UnitParser.jar

-693 KB
Binary file not shown.
-576 KB
Binary file not shown.

all_code/Test/.classpath

Lines changed: 0 additions & 6 deletions
This file was deleted.

all_code/Test/.project

Lines changed: 0 additions & 17 deletions
This file was deleted.

all_code/Test/.settings/org.eclipse.core.resources.prefs

Lines changed: 0 additions & 2 deletions
This file was deleted.

all_code/Test/.settings/org.eclipse.jdt.core.prefs

Lines changed: 0 additions & 12 deletions
This file was deleted.

all_code/Test/.settings/org.eclipse.ltk.core.refactoring.prefs

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)