g_calc

Crates.iog_calc
lib.rsg_calc
version0.1.1
sourcesrc
created_at2022-09-19 04:00:16.176322
updated_at2022-09-19 04:42:45.082295
descriptionA small utility for performing simple math calculations using infix expression
homepage
repository
max_upload_size
id668906
size8,655
Gokulakannan (gokulakannan1905)

documentation

README

g_calc

Simple calculator utility written in rust

Installation

Add this to your Cargo.toml:

[dependencies]
g_calc = "0.1.1"

Usage

use g_calc::{convert,solve};

let sample_expr = "1 + 2 * 3";

//this fn converts the given infix expression to postfix expression
let postfix_expr = g_calc::convert(sample_expr).unwrap();

//this fn solves the postfix expression and returns the result
let output = g_calc::solve(postfix_expr).unwrap();
// output = 7    

works for basic math calculations

  • exponentiation ( ^ )
  • add, substract, multiplication, division
  • supports decimal notation ( eg., 0.1 + 0.2)
  • parentheses support ()
Commit count: 0

cargo fmt