Skip to content

Commit bcff6c6

Browse files
committed
Initial DeepMath commit
0 parents  commit bcff6c6

File tree

6 files changed

+495
-0
lines changed

6 files changed

+495
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
2+
/**
3+
* DeepMath - Arduino Library for Large Number & Decimal Math
4+
* -----------------------------------------------------------
5+
* Author: Hafiz Amanudeen Pallimukku
6+
* Version: 1.0
7+
* License: MIT
8+
*
9+
* Description:
10+
* This library allows operations on large numbers and precise decimal math
11+
* without relying on Arduino's limited floating point.
12+
*
13+
* Features:
14+
* - Convert between String and unsigned long long
15+
* - Analyze decimal strings (length, integer part, no decimal, etc.)
16+
* - Perform manual arithmetic (+, -, *, /) on large decimal numbers
17+
*
18+
* Usage Example:
19+
* #include <DeepMath.h>
20+
* DeepMath math;
21+
* Serial.println(math.CALC("45.50", '+', "54.25")); // 99.75
22+
* For more information, refer to the README.md file in the DeepMath library folder.
23+
24+
*/
25+
26+
27+
28+
#include <DeepMath.h>
29+
DeepMath math;
30+
void setup() {
31+
Serial.begin(9600);
32+
33+
long long num = 1234567890123456789LL;
34+
35+
// Convert large number to string
36+
String result = math.LtoS(num);
37+
Serial.println(result);
38+
39+
// Convert string to large number
40+
Serial.println(math.StoL(result));
41+
42+
// Get total number of digits (including decimals)
43+
Serial.println(math.AnalyseStr("34.567", 'T')); // Output: 6
44+
45+
// Remove decimal point and return pure number
46+
Serial.println(math.AnalyseStr("123.4567", '0')); // Output: 1234567
47+
48+
// Get number of digits before the decimal point
49+
Serial.println(math.AnalyseStr("123.4567", 'F')); // Output: 3
50+
51+
// Get only the integer part (truncate decimal)
52+
Serial.print("Integer part of 1234.567: ");
53+
Serial.println(math.AnalyseStr("1234.567", '#')); // Output: 1234
54+
55+
// Arithmetic operations on large decimal values
56+
Serial.println(math.CALC("35.74537", '*', "1.223538",0)); // Multiplication
57+
Serial.println(math.CALC("36.56776878", '/', "12.234567",6)); // Division
58+
Serial.println(math.CALC("43.23849487", '+', "6.832734",0)); // Addition
59+
Serial.println(math.CALC("68.323327", '-', "43.2367237",0)); // Subtraction
60+
}
61+
62+
void loop() {
63+
// Your code here
64+
}
65+
66+
67+

License.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
MIT License
3+
4+
Copyright (c) 2025 Hafiz Amanudeen Pallimukku
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/

README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# DeepMath
2+
DeepMath is a lightweight Arduino library by "Hfiz Amanudeen pallimukku"for performing high-precision decimal and large number arithmetic operations without using floating point types (float or double) or external libraries like sprintf, string, or stringstream.
3+
4+
This library is designed for use in memory-limited microcontrollers (such as ESP32-Wroom,ATmega328, ESP32-CAM, etc.) where standard math functions are not reliable for large or precise decimal operations.
5+
6+
📘 Usage
7+
cpp
8+
9+
#include <DeepMath.h>
10+
11+
void setup() {
12+
Serial.begin(9600);
13+
14+
long long num = 1234567890123456789LL;
15+
16+
// Convert large number to string
17+
String re
18+
---
19+
20+
## ✨ Features
21+
22+
- Pure logic-based implementation
23+
- Works with very large integers (`long long`, `unsigned long long`)
24+
- Supports:
25+
- Integer to String conversion (up to 20 digits)
26+
- Decimal point insertion without float
27+
- Manual power, division, and addition logic
28+
- Minimal dependencies (`Arduino.h` and `math.h` only)
29+
- No dynamic memory allocation (`malloc`, `new`, etc.)
30+
31+
---
32+
33+
## 🔧 Installation
34+
35+
### Method 1: Manually
36+
37+
1. Download or clone this repository:
38+
2. Move the folder into your Arduino libraries directory:
39+
40+
### Method 2: Zip Import
41+
42+
1. Go to Arduino IDE → Sketch → Include Library → Add .ZIP Library.
43+
2. Select the zipped DeepMath folder.
44+
45+
---
46+
47+
## 📘 Usage
48+
49+
```cpp
50+
#include <DeepMath.h>
51+
DeepMath math;
52+
void setup() {
53+
Serial.begin(9600);
54+
55+
long long num = 1234567890123456789LL;
56+
57+
// Convert large number to string
58+
String result = math.LtoS(num);
59+
Serial.println(result);
60+
61+
// Convert string to large number
62+
Serial.println(math.StoL(result));
63+
64+
// Get total number of digits (including decimals)
65+
Serial.println(math.AnalyseStr("34.567", 'T')); // Output: 6
66+
67+
// Remove decimal point and return pure number
68+
Serial.println(math.AnalyseStr("123.4567", '0')); // Output: 1234567
69+
70+
// Get number of digits before the decimal point
71+
Serial.println(math.AnalyseStr("123.4567", 'F')); // Output: 3
72+
73+
// Get only the integer part (truncate decimal)
74+
Serial.print("Integer part of 1234.567: ");
75+
Serial.println(math.AnalyseStr("1234.567", '#')); // Output: 1234
76+
77+
// Arithmetic operations on large decimal values
78+
Serial.println(math.CALC("35.74537", '*', "1.223538",0)); // Multiplication
79+
Serial.println(math.CALC("36.56776878", '/', "12.234567",5)); // Division
80+
Serial.println(math.CALC("43.23849487", '+', "6.832734",0)); // Addition
81+
Serial.println(math.CALC("68.323327", '-', "43.2367237",0)); // Subtraction
82+
}
83+
84+
void loop() {
85+
// Your code here
86+
}
87+
88+
89+
90+

library.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=DeepMath
2+
version=1.0.0
3+
author=Hafiz Amanudeen Pallimukku
4+
maintainer=Hafiz Amanudeen Pallimukku <your-email@example.com>
5+
sentence=Decimal and large number math operations without using float/double.
6+
paragraph=This library provides decimal math operations (add, subtract, multiply, divide) using string and long long logic instead of floating point math. Useful for large number calculations in Arduino.
7+
category=Math
8+
url=https://github.com/yourusername/DeepMath
9+
architectures=*

0 commit comments

Comments
 (0)