11 сент. 2013 г. · You need pow(); function from math.h header. syntax #include <math.h> double pow(double x, double y); float powf(float x, float y); ... |
15 сент. 2015 г. · Assuming you mean n = 2x, then this is called logarithm base 2. In C you can write: double n = 512; // ... double x = log(n) / log(2); // 9. |
1 мар. 2009 г. · There's a simple trick for this problem: bool IsPowerOfTwo(ulong x) { return (x & (x - 1)) == 0; } Note, this function will report true for 0, which is not a ... |
12 нояб. 2018 г. · I am trying to create a program that displays an integer in an array if it is a power of two. ex; an array contains the integer (1,2,4,9) it will print 1,2 and ... |
17 мар. 2021 г. · A power of 2 can be found by shifting: 2-to-the-N is obtained from 1 << N. For other bases an alternative to the brute-force multiplication loop is ... |
27 февр. 2022 г. · I already made program, for one number to test if that number is power of 2. But I have problem, and I don't know how to fix it. But I need to make program ... |
13 мар. 2013 г. · I'm struggling trying to figure out the right way to scan to integers in, the first being my x variable and second being the n which x is being raised to. |
3 июн. 2011 г. · You could use the log function in cmath... double exponent = log(number)/log(2.0); ...and then cast it to an int afterwards. If that number is ... |
24 апр. 2014 г. · What you want to do is count the trailing zeroes of a number, although counting the leading zeroes and subtracting from 32 or 64 can work ... |
30 авг. 2020 г. · Given a positive integer which fits in a 32 bit signed integer, find if it can be expressed as A^P where P > 1 and A > 0. A and P both should be integers. |
Novbeti > |
Axtarisha Qayit Anarim.Az Anarim.Az Sayt Rehberliyi ile Elaqe Saytdan Istifade Qaydalari Anarim.Az 2004-2023 |