Skip to content

This library allows operations on large numbers and precise decimal math without relying on Arduino's limited floating point.

License

AS-INVENTIONS/DeepMath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📐 DeepMath - High Precision Math for Arduino

DeepMath is a lightweight and dependency-free Arduino library by Hafiz Amanudeen Pallimukku for performing high-precision decimal and large-number arithmetic operations without using float, double, or complex string-based libraries like sprintf, string, or stringstream.

Designed especially for memory-constrained microcontrollers like ESP32-WROOM, ESP32-CAM, ATmega328, etc., where native floating point operations are not reliable or precise for large values.


✨ Features

  • ✅ Pure logic-based implementation (no floating point math)
  • 🔢 Works with very large integers (long long, unsigned long long)
  • 🔧 Manual implementations of:
    • Integer-to-string and string-to-integer conversion
    • Decimal point handling
    • Power, division, addition logic
  • 🪶 Minimal dependencies (Arduino.h, math.h)
  • 🚫 No dynamic memory (malloc, new, etc.)

🔧 Installation

🔹 Method 1: Manual

  1. Download or clone this repository.
  2. Move the folder into your Arduino libraries directory.

🔹 Method 2: ZIP Import

  1. Open Arduino IDESketchInclude LibraryAdd .ZIP Library.
  2. Select the zipped DeepMath folder.

📘 Basic Usage

#include <DeepMath.h>
DeepMath math;
void setup() {
  Serial.begin(9600);

  long long num = 1234567890123456789LL;

  // Convert large number to string
  String result = math.LtoS(num);
  Serial.println(result);

  // Convert string to large number
  Serial.println(math.StoL(result));

  // Get total number of digits (including decimals)
  Serial.println(math.LtoS(math.AnalyseStr("34.567", 'T'))); // Output: 6

  // Remove decimal point and return pure number
  Serial.println(math.LtoS(math.AnalyseStr("123.4567", '0'))); // Output: 1234567

  // Get number of digits before the decimal point
  Serial.println(math.LtoS(math.AnalyseStr("123.4567", 'F'))); // Output: 3

  // Get only the integer part (truncate decimal)
  Serial.print("Integer part of 1234.567: ");
  Serial.println(math.LtoS(math.AnalyseStr("1234.567", '#'))); // Output: 1234

  // Arithmetic operations on large decimal values
  Serial.println(math.CALC("35.74537", '*', "1.223538",0));    // Multiplication
  Serial.println(math.CALC("36.56776878", '/', "12.234567",6)); // Division
  Serial.println(math.CALC("43.23849487", '+', "6.832734",0));  // Addition
  Serial.println(math.CALC("68.323327", '-', "43.2367237",0));  // Subtraction
}

void loop() {
  // Your code here
}
void loop() {
  // Optional: continuous tasks
}

About

This library allows operations on large numbers and precise decimal math without relying on Arduino's limited floating point.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages