return (i == -3) ? 1: 0;
That line is not a bad practice, but a terrible and horrible one.
Type: Posts; User: ZTik
return (i == -3) ? 1: 0;
That line is not a bad practice, but a terrible and horrible one.
I meant pointer arithmetic. In the case of maintainability, there are people who write bad code that they don't understand 6 months from now. Or is it bad people who write bad code, in the sense of...
Hello,
For the sake of portable code,
using pointers and unsigned integers can make code hard to read for certain people,
consequently an entire project becomes less portable, if delegated to the...
Hello,
I find too many lines makes a function much longer and adds to the entire project.
Is it a bad idea to use these ?
x = a < 3;
That is not practical rounding from high school.
I am not using a float or a double.
I am not using printf or printf method of rounding.
Does -0.001 "rounded-down" become 0.00, that's all I want to know.
Please, elaborate..
This is quite an obscure bit of trivia.
-4.001 at 2 decimal place = -3.99
-1.001 at 2 decimal place = -0.99
-0.001 at 2 decimal place = ?
The answer is 0.00, since the difference between 399...
My mistake, I meant greater-less than operator.
This implementation is correct but inefficient.
static int lessThan(int number1, int number2) {
int i = 1;
while (number1 && number2) {
number1 = number1 - 1;
...
For now I will stick to the division implementation, the addition one is efficient.
The problem to solve was to avoid using Math header, library function and the shift-mask operators.
In that case the only option was to use the division and the remainder % operators.
static const int32_t getExponent(uint32_t binary) {
uint32_t b, e = 0, i = 8, power;
binary /= 8388608;
while (i--) {
b = binary;
power = i;
while (power--)...
int main(int argc, const char *argv[]) {
const float i = 263.3;
printf("Exponent = %d\n", ((*(__uint32_t *)&i / 8388608) % 255) - 127);
return 0;
}
Solved, but I really need to...
I don't want to use Math header or Union.
The mask is 0b11111111 which is 8 digits, there must be a way to loop 8-times and extract the bias-exponent.
int main(int argc, const char *argv[]) {...
Hello,
Is there a way to get the exponent of a number without using shift and mask operators.
I can remove the mantissa using division which is equivalent to shifting,
but I am stuck at masking....