npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

adv_calculator

v1.1.8

Published

Scientific Calculator

Downloads

356

Readme

Arithmetic Functions Module

A Node.js module providing basic arithmetic functions: addition, subtraction, multiplication, and division. This module is designed for educational purposes to demonstrate how to write and test JavaScript functions.

Table of Contents

Overview

This module includes the following functions:

Arithmetic Functions

  • add(a, b): Returns the sum of a and b.
  • subtract(a, b): Returns the difference when b is subtracted from a.
  • multiply(a, b): Returns the product of a and b.
  • divide(a, b): Returns the quotient when a is divided by b. Throws an error if b is zero.
  • exponential(base, exponent): Returns the result of base raised to the power of exponent.
  • modulus(a, b): Returns the remainder when a is divided by b.
  • squareRoot(a): Returns the square root of a.
  • absolute(a): Returns the absolute value of a.
  • factorial(n): Returns the factorial of n.
  • gcd(a, b): Returns the greatest common divisor of a and b.
  • lcm(a, b): Returns the lowest common multiple of a and b.

Bitwise Functions

  • bitwiseAnd(a, b): Performs a bitwise AND operation on a and b.
  • bitwiseOr(a, b): Performs a bitwise OR operation on a and b.
  • bitwiseXor(a, b): Performs a bitwise XOR operation on a and b.
  • bitwiseNot(a): Performs a bitwise NOT operation on a.
  • leftShift(a, b): Performs a left bitwise shift on a by b bits.
  • rightShift(a, b): Performs a right bitwise shift on a by b bits.
  • zeroFillRightShift(a, b): Performs a zero-fill right shift on a by b bits.

Installation

To use this module in your project, follow these steps:

  1. Clone the repository:

    git clone https://github.com/TyRoopam9599/adv_calculator.git
  2. Navigate to the project directory:

    cd adv_calculator
  3. Install dependencies:

    This project uses Mocha for testing. Install it along with other dependencies using:

    npm install

Usage

You can use the functions by requiring the module in your Node.js application. Here’s how you can do it:

const { 
  add, 
  subtract, 
  multiply, 
  divide, 
  exponential, 
  modulus, 
  bitwiseAnd, 
  bitwiseOr, 
  bitwiseXor, 
  bitwiseNot, 
  leftShift, 
  rightShift, 
  zeroFillRightShift, 
  squareRoot, 
  absolute, 
  factorial,
  gcd,
  lcm
} = require('./index');

console.log(add(2, 3));         // Output: 5
console.log(subtract(5, 2));    // Output: 3
console.log(multiply(2, 3));    // Output: 6
console.log(divide(6, 2));      // Output: 3
console.log(modulus(5, 2));     // Output: 1
console.log(exponential(2, 3)); // Output: 8
console.log(squareRoot(9));     // Output: 3
console.log(absolute(-5));      // Output: 5
console.log(factorial(5));      // Output: 120
console.log(gcd(5,2)) ;         // Output: 1
condole.log(lcm(5,2)) ;         // Output: 10

console.log(bitwiseAnd(5, 3));  // Output: 1
console.log(bitwiseOr(5, 3));   // Output: 7
console.log(bitwiseXor(5, 3));  // Output: 6
console.log(bitwiseNot(5));     // Output: -6
console.log(leftShift(5, 1));   // Output: 10
console.log(rightShift(5, 1));  // Output: 2
console.log(zeroFillRightShift(5, 1)); // Output: 2

// Handle division by zero
try {
  console.log(divide(6, 0));
} catch (error) {
  console.error(error.message); // Output: Cannot divide by zero
}