Search:

Type: Posts; User: ZTik

Search: Search took 0.01 seconds.

  1. Replies
    7
    Views
    5,366

    return (i == -3) ? 1: 0; That line is not a...

    return (i == -3) ? 1: 0;

    That line is not a bad practice, but a terrible and horrible one.
  2. Replies
    5
    Views
    4,022

    I meant pointer arithmetic. In the case of...

    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...
  3. Replies
    5
    Views
    4,022

    Portable code and Illiterate programmers.

    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...
  4. Replies
    7
    Views
    5,366

    Production Code and Good Practices.

    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;
  5. Replies
    11
    Views
    6,680

    That is not practical rounding from high school.

    That is not practical rounding from high school.
  6. Replies
    11
    Views
    6,680

    I am not using a float or a double.

    I am not using a float or a double.
  7. Replies
    11
    Views
    6,680

    I am not using printf or printf method of...

    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.
  8. Replies
    11
    Views
    6,680

    Please, elaborate..

    Please, elaborate..
  9. Replies
    11
    Views
    6,680

    Round A Negative Number

    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...
  10. My mistake, I meant greater-less than operator.

    My mistake, I meant greater-less than operator.
  11. Find if number x is less than y without 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;
    ...
  12. Replies
    16
    Views
    14,587

    For now I will stick to the division...

    For now I will stick to the division implementation, the addition one is efficient.
  13. Replies
    16
    Views
    14,587

    The problem to solve was to avoid using Math...

    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.
  14. Replies
    16
    Views
    14,587

    static const int32_t getExponent(uint32_t binary)...

    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--)...
  15. Replies
    16
    Views
    14,587

    int main(int argc, const char *argv[]) { ...

    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...
  16. Replies
    16
    Views
    14,587

    I don't want to use Math header or Union. The...

    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[]) {...
  17. Replies
    16
    Views
    14,587

    Get Exponent of A Float

    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....
Results 1 to 17 of 17