libcalculator 1.0.0 copy "libcalculator: ^1.0.0" to clipboard
libcalculator: ^1.0.0 copied to clipboard

A mathematical expression evaluator for Dart that handles arithmetic operations, parentheses, decimal numbers, and proper operator precedence with precise calculations.

example/libcalculator_example.dart

import 'package:libcalculator/libcalculator.dart';

void main() {
  final Calculator calculator = Calculator();

  // Basic operations
  print('2 + 3 * 4 = ${calculator.calculate('2+3*4')}');
  print('10 / 2 + 3 = ${calculator.calculate('10/2+3')}');
  print('5 * 2 - 3 = ${calculator.calculate('5*2-3')}');

  // Parentheses examples
  print('(2 + 3) * 4 = ${calculator.calculate('(2+3)*4')}');
  print('2 * (3 + 4) = ${calculator.calculate('2*(3+4)')}');
  print('((1 + 2) * 3) + 4 = ${calculator.calculate('((1+2)*3)+4')}');

  // Decimal operations
  print('3.5 + 2.1 = ${calculator.calculate('3.5+2.1')}');
  print('(2.5 + 1.5) * 2 = ${calculator.calculate('(2.5+1.5)*2')}');
}
1
likes
0
points
26
downloads

Publisher

unverified uploader

Weekly Downloads

A mathematical expression evaluator for Dart that handles arithmetic operations, parentheses, decimal numbers, and proper operator precedence with precise calculations.

Repository (GitHub)
View/report issues

Topics

#calculator #mathematics

License

unknown (license)

More

Packages that depend on libcalculator