Skip to content

Commit 38b08fc

Browse files
2.1.0 - small API improvements, extended documentation
1 parent 09b9295 commit 38b08fc

File tree

266 files changed

+13704
-100
lines changed

Some content is hidden

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

266 files changed

+13704
-100
lines changed

CURRENT/README.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
mXparser - Math Parser Java C# .NET (CLS) Library beta
22
A flexible mathematical expressions parser for JAVA and C# .NET (CLS)
33

4+
v.2.1.0 (2016-01-02):
5+
* New static methods in class mxparser
6+
- mXparser.numberToHexString(number) + overloads: int, long, double
7+
- mXparser.hexString2AsciiString(String hexString)
8+
- mXparser.numberToAsciiString(number) + overloads: int, long, double
9+
- additional regression tests for the above methods
10+
11+
* Hello World examples of how to use mXparser binary library (manual includes:
12+
projects, code, screenshots) for:
13+
- JAVA (project done in Eclipse Mars 1)
14+
- C# (project done in Visual Studio 2015)
15+
- Visual Basic (project done in Visual Studio 2015)
16+
- C++/CLI (project done in Visual Studio 2015)
17+
- F# (project done in Visual Studio 2015)
18+
419
v.2.0.0 (2015-12-31): Major update of the library providing more intuitive and
520
much simpler to use API, no changes to the MathCollection.
621

-1 KB
Binary file not shown.

CURRENT/c-sharp/RegTestExpressionV2.cs

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* @(#)RegTestExpression.cs 2.0.0 2015-12-29
2+
* @(#)RegTestExpression.cs 2.1.0 2016-01-01
33
*
44
* You may use this software under the condition of "Simplified BSD License"
55
*
@@ -64,7 +64,7 @@ namespace org.mariuszgromada.math.mxparser.regressiontesting
6464
* <a href="http://mariuszgromada.github.io/MathParser.org-mXparser/" target="_blank">mXparser on GitHub pages</a><br>
6565
* <a href="http://mxparser.sourceforge.net/" target="_blank">mXparser on SourceForge/</a><br>
6666
*
67-
* @version 2.0.0
67+
* @version 2.1.0
6868
*
6969
* @see Expression
7070
*/
@@ -4762,6 +4762,36 @@ private static bool runTest(int testId) {
47624762
mXparser.consolePrint(value + " reg ... " + reg + " --> ");
47634763

47644764
break;
4765+
case 287:
4766+
4767+
expStr = "5^2 * 7^3 * 11^1 * 67^1 * 49201^1";
4768+
4769+
mXparser.consolePrint(expStr + " ...... ");
4770+
exp[testId] = new Expression(expStr);
4771+
String hello = mXparser.numberToAsciiString(exp[testId].calculate());
4772+
String regHello = "Hello";
4773+
4774+
if ( regHello.Equals(hello) )
4775+
testResult = true;
4776+
4777+
mXparser.consolePrint(hello + " reg ... " + regHello + " --> ");
4778+
4779+
break;
4780+
case 288:
4781+
4782+
expStr = "71^1 * 218549^1 * 6195547^1";
4783+
4784+
mXparser.consolePrint(expStr + " ...... ");
4785+
exp[testId] = new Expression(expStr);
4786+
String world = mXparser.numberToAsciiString(exp[testId].calculate());
4787+
String regWorld = "World!";
4788+
4789+
if ( regWorld.Equals(world) )
4790+
testResult = true;
4791+
4792+
mXparser.consolePrint(world + " reg ... " + regWorld + " --> ");
4793+
4794+
break;
47654795

47664796

47674797
}
@@ -4783,7 +4813,7 @@ private static bool runTest(int testId) {
47834813
*/
47844814
public static void Start() {
47854815
// TODO Auto-generated method stub
4786-
int numberOfTests = 286;
4816+
int numberOfTests = 288;
47874817
int nOk = 0;
47884818
int nError = 0;
47894819
exp = new Expression[numberOfTests+1];
512 Bytes
Binary file not shown.
4 KB
Binary file not shown.

CURRENT/c-sharp/mXparser.cs

Lines changed: 99 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* @(#)mXparser.cs 2.0.0 2015-12-29
2+
* @(#)mXparser.cs 2.1.0 2016-01-01
33
*
44
* You may use this software under the condition of "Simplified BSD License"
55
*
@@ -43,6 +43,7 @@
4343
using System;
4444
using System.Collections.Generic;
4545
using System.Text.RegularExpressions;
46+
using System.Globalization;
4647

4748
[assembly: CLSCompliant(true)]
4849

@@ -62,7 +63,7 @@ namespace org.mariuszgromada.math.mxparser {
6263
* <a href="http://mariuszgromada.github.io/MathParser.org-mXparser/" target="_blank">mXparser on GitHub pages</a><br>
6364
* <a href="http://mxparser.sourceforge.net/" target="_blank">mXparser on SourceForge/</a><br>
6465
*
65-
* @version 2.0.0
66+
* @version 2.1.0
6667
*
6768
* @see RecursiveArgument
6869
* @see Expression
@@ -136,6 +137,101 @@ public static double[] arraList2double(List<Double> numbers) {
136137

137138
}
138139

140+
/**
141+
* Converts integer number to hex string (plain text)
142+
*
143+
* @param number Integer number
144+
* @return Hex string (i.e. FF23)
145+
*/
146+
public static String numberToHexString(int number)
147+
{
148+
return number.ToString("X");
149+
}
150+
151+
/**
152+
* Converts long number to hex string (plain text)
153+
*
154+
* @param number Long number
155+
* @return Hex string (i.e. FF23)
156+
*/
157+
public static String numberToHexString(long number)
158+
{
159+
return number.ToString("X");
160+
}
161+
162+
/**
163+
* Converts (long)double number to hex string (plain text)
164+
*
165+
* @param number Double number
166+
* @return Hex string (i.e. FF23)
167+
*/
168+
public static String numberToHexString(double number)
169+
{
170+
return numberToHexString((long)number);
171+
}
172+
173+
174+
/**
175+
* Converts hex string into ASCII string, where each letter is
176+
* represented by two hex digits (byte) from the hex string.
177+
*
178+
* @param hexString Hex string (i.e. 48656C6C6F)
179+
* @return ASCII string (i.e. '48656C6C6F' = 'Hello')
180+
*/
181+
public static String hexString2AsciiString(String hexString)
182+
{
183+
String hexByteStr;
184+
int hexByteInt;
185+
String asciiString = "";
186+
for (int i = 0; i < hexString.Length; i += 2)
187+
{
188+
hexByteStr = hexString.Substring(i, 2);
189+
hexByteInt = int.Parse(hexByteStr, NumberStyles.HexNumber);
190+
asciiString = asciiString + (char)hexByteInt;
191+
}
192+
return asciiString;
193+
}
194+
195+
/**
196+
* Converts number into ASCII string, where each letter is
197+
* represented by two hex digits (byte) from the hex representation
198+
* of the original number
199+
*
200+
* @param number Integer number (i.e. 310939249775 = '48656C6C6F')
201+
* @return ASCII string (i.e. '48656C6C6F' = 'Hello')
202+
*/
203+
public static String numberToAsciiString(int number)
204+
{
205+
return hexString2AsciiString(numberToHexString(number));
206+
}
207+
208+
/**
209+
* Converts number into ASCII string, where each letter is
210+
* represented by two hex digits (byte) from the hex representation
211+
* of the original number
212+
*
213+
* @param number Long number (i.e. 310939249775 = '48656C6C6F')
214+
* @return ASCII string (i.e. '48656C6C6F' = 'Hello')
215+
*/
216+
public static String numberToAsciiString(long number)
217+
{
218+
return hexString2AsciiString(numberToHexString(number));
219+
}
220+
221+
/**
222+
* Converts (long)double number into ASCII string, where each letter is
223+
* represented by two hex digits (byte) from the hex representation
224+
* of the original number casted to long type.
225+
*
226+
* @param number Double number (i.e. 310939249775 = '48656C6C6F')
227+
* @return ASCII string (i.e. '48656C6C6F' = 'Hello')
228+
*/
229+
public static String numberToAsciiString(double number)
230+
{
231+
return hexString2AsciiString(numberToHexString(number));
232+
}
233+
234+
139235
/**
140236
* Prints object.toString to the Console + new line
141237
*
@@ -150,7 +246,7 @@ public static void consolePrintln() {
150246
}
151247

152248
/**
153-
* Prints object.toString to the Console
249+
* Prints object.toString to the Console, no new line
154250
*
155251
* @param o Object to print
156252
*/

CURRENT/c-sharp/mXparserExe/RegTestRun.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ public static void Main(String[] args)
1414
{
1515
//Thread T1 = new Thread(RegTestExpression.Start, 536870912);
1616
//T1.Start();
17-
//Thread T2 = new Thread(RegTestExpressionV2.Start, 536870912);
18-
//T2.Start();
17+
/// Thread T2 = new Thread(RegTestExpressionV2.Start, 536870912);
18+
///T2.Start();
1919
//Thread T3 = new Thread(RegTestExpressionAPI.Start);
2020
//T3.Start();
2121
//Thread T5 = new Thread(RegTestSyntax.Start);
2222
//T5.Start();
2323

24-
PerformanceTests.Start();
24+
PerformanceTests.Start();
2525
}
2626
}
2727
}
0 Bytes
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)