Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > fuction to divide by three

Reply
Thread Tools

fuction to divide by three

 
 
user923005
Guest
Posts: n/a
 
      05-29-2007
On May 28, 3:15 pm, "christian.bau" <(E-Mail Removed)>
wrote:
> On May 26, 3:30 pm, (E-Mail Removed) wrote:
>
> > Without using /,% and * operators. write a function to divide a
> > number by 3.
> > itoa() function is available

>
> double divide_by_3 (double x) {
> return x > 0.0 ? exp (log (x) - log (3.0)) :
> x < 0.0 ? -exp (log (-x) - log (3.0)) : x;
> }


I like this one. I do see a minor problem for x == 0.

 
Reply With Quote
 
 
 
 
user923005
Guest
Posts: n/a
 
      05-29-2007
On May 29, 11:21 am, user923005 <(E-Mail Removed)> wrote:
> On May 28, 3:15 pm, "christian.bau" <(E-Mail Removed)>
> wrote:
>
> > On May 26, 3:30 pm, (E-Mail Removed) wrote:

>
> > > Without using /,% and * operators. write a function to divide a
> > > number by 3.
> > > itoa() function is available

>
> > double divide_by_3 (double x) {
> > return x > 0.0 ? exp (log (x) - log (3.0)) :
> > x < 0.0 ? -exp (log (-x) - log (3.0)) : x;
> > }

>
> I like this one. I do see a minor problem for x == 0.


As the wise baboon in "The Lion King" or Ben Pfaff might say:
"Look Harder."

Indeed, the matter is cared for.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Three Mobile --> Skype on three (Non-three [Symbian - Nokia] handsets) Harry Stottle UK VOIP 0 01-05-2010 08:59 AM
i used lots of static fuction is it ok? mike ASP .Net 3 11-16-2005 03:06 AM
I'd like to conver long value to IP address, which fuction do I have to use? somez72 Java 4 05-03-2004 09:27 PM
An allocated variable returning by a fuction is unallocated automatically ? orion30 C++ 2 07-14-2003 10:39 AM
Re: reverse Fuction "Segmentation fault" MiniDisc_2k2 C++ 2 07-03-2003 02:52 PM



Advertisments