Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

40,039 questions

52,004 answers

573 users

How to use logb() function to calculate the logarithm of |N|, using FLT_RADIX (2) as base in C

1 Answer

0 votes
#include <stdio.h>     
#include <math.h> 
 
int main(int argc, char **argv)
{   
    printf("logb(1) = %f\n", logb(1));    
	printf("logb(1024) = %f\n", logb(1024));
	printf("logb(512) = %f\n", logb(512));
	printf("logb(5) = %f\n", logb(5));
	printf("logb(100) = %f\n", logb(100));
	printf("logb(125) = %f\n", logb(125));	
	printf("logb(125) / logb(5) = %f\n", logb(125) / logb(5));
	printf("logb(123.65) = %lf\n", logb(123.65));
	printf("logb(1000) = %f\n", logb(1000));
    printf("logb(0.001) = %f\n", logb(0.001));
  
    return 0;
}
 
 
/*
run:
   
logb(1) = 0.000000
logb(1024) = 10.000000
logb(512) = 9.000000
logb(5) = 2.000000
logb(100) = 6.000000
logb(125) = 6.000000
logb(125) / logb(5) = 3.000000
logb(123.65) = 6.000000
logb(1000) = 9.000000
logb(0.001) = -10.000000

*/

 



answered Mar 26, 2016 by avibootz
...