Member Avatar for creck

Hi guys, I am a novice in C programming, and would like to ask you for help as I've started studying a computer science at university just few weeks ago. All I need to do is write a math function "pow(double x, double y)" without using any of functions in math.h library. There's no problem to do it for me if "y" is an integer number, but once it gets and float value, I am lost. For example how would you solve this one case: 2^3.56
Thanks in advance

Regards
Creck

Recommended Answers

All 3 Replies

Wait, you're a novice and you've been given an assignment to write a floating point pow() without any math.h functions in the first few weeks of a CS course? Something seems off there, because this isn't exactly a trivial exercise.

For example, take a look at the implementations here. They're designed to be short and simple, yet pow() still depends on a relatively large amount of scaffolding.

Member Avatar for creck

Yeah, exactly as you wrote; I am currently attending first semester at university...All I have ever been programming were some trivial functions at high school in PASCAL and now after few weeks being here I got to create a project with few math functions without using math.h library. One of that function is pow with floating point :/ Thanks for that link deceptikon, I am gonna take a look on it.

Member Avatar for creck

Well, I have already took a look on that, but have no idea where to start at all :/ Do u have any advices how could I start ? Any principle how does it work?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.