Skip to content

prabhav951/power-function-in-C

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Implementation of pow() function in C

To calculate x^n, considering two cases

  • intPower(x, n)

    • x and n, both are of int data type
  • floatPower(x, n)

    • x and n, both are of float data type -

Assumptions

  • The intPower and floatPower functions only work when x^n doesn't cross the range of double type
  • The intPower and floatPower functions return INT_MAX (indicating error), when ans=0^(-ve number) or ans=(-ve number)^(non-integer number). Hence both the functions fail only at the case x=INT_MAX and n=1
  • The floatPower function takes all floating point numbers of x, n except the range ( (-inf < x < 0) and (n is not an integer) )

Screen Shots

Case1 - x,n are ints

x,n are ints

Case2 - x,n are floats

x,n are floats

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages