Search:

Type: Posts; User: flp1969

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    37
    Views
    618

    Here's how: 16365

    Here's how:
    16365
  2. Ahhhh... of course: 16363 I just don't know if...

    Ahhhh... of course:
    16363
    I just don't know if double precision is sufficient to hold factorials of "big" numbers (like INT_MAX-2).

    Testing here: 171 will cause overflow! 1755! overflows for...
  3. You do notice that your function is not well...

    You do notice that your function is not well behaved for some values of x, don't you?
    16361
    And it's worse: The denominator isn't continuous for a lot of values (if considering x integer, it is...
  4. Replies
    11
    Views
    182

    rand() is a pseudo random number generator. It...

    rand() is a pseudo random number generator. It isn't really random, just appears to be. It depends on the initial value seeded to the algorithm. If this value is 12, rand() will always give you the...
  5. If the code is too complex for you to fix for...

    If the code is too complex for you to fix for Windows (I don't do Windows in 14 years), then forget it... The explanation in post #9 should be sufficient.

    And, yet... you forget, in both codes, to...
  6. In essence it is the same thing. I've only notice...

    In essence it is the same thing. I've only notice that any comparison results in 0 or 1 (not other values)... The if:


    bin = n & 0x80; // isolate bit 7.
    if ( bin == 1)
    s[i] = '1';
    else
    ...
  7. Another thing: All numeric representations in a...

    Another thing: All numeric representations in a computer are binary. When you do

    int x = 10;
    This "decimal" 10 is encoded in binary and put in memory (or register) as a binary value. So, you can...
  8. Replies
    3
    Views
    174

    General rule: for is only a clever way to write...

    General rule: for is only a clever way to write while loops. With your example:

    for (int i = 0, j = n - 1; i < j; i++, j--)
    doSomething();
    Is the same as:

    /* block, because i and j are...
  9. As hamster_nz said, there is a problem of...

    As hamster_nz said, there is a problem of rounding when using floating point, specially with pow(), since the power is calculated as:
    16359
    The natural logarithm is approximated, and the...
  10. Neither do I... It is a valid point, since MinGW...

    Neither do I... It is a valid point, since MinGW uses MSVCRT??.dll and maybe pow() is implemented there.
  11. This is also my suspicion... Since x^y (^ as...

    This is also my suspicion... Since x^y (^ as potency) is calculated as e^(y*ln(x)) and, maybe, MinGW implementation of pow() can be a little bit wrong (there's a final approximation that need to be...
  12. I have my suspicions: Please compile and run this...

    I have my suspicions: Please compile and run this program and post what is printed (on Windows) -- don't forget to link the libm library.

    /* test.c */

    #include <stdio.h>
    #include <math.h>
    ...
  13. Replies
    3
    Views
    512

    john.c and stahta01 have a point (sorry didn't...

    john.c and stahta01 have a point (sorry didn't resist the pun).

    You are dealing with triangle SIDES, not vertices. And choosing 3 random values between -10 and 10:


    rand()/(float)RAND_MAX ->...
  14. Replies
    5
    Views
    431

    I can

    I can
  15. Replies
    6
    Views
    363

    Shoudn't be %f instead of %d?

    Shoudn't be %f instead of %d?
  16. Replies
    5
    Views
    384

    Selection sort... walk through the first element...

    Selection sort... walk through the first element to the last but one (i). Inside that loop, walk to the second element to the last (j). Compare element at position i to the element at position j. If...
  17. Replies
    15
    Views
    644

    /proc/mounts or /proc/self/mounts

    /proc/mounts or /proc/self/mounts
  18. Thread: Win-bash use

    by flp1969
    Replies
    5
    Views
    745

    Another thing: This is not valid: $ x = 1 x:...

    Another thing: This is not valid:

    $ x = 1
    x: command not found

    Assignments must not have spaces:

    $ x=1
    $ echo $x
    1
  19. Replies
    11
    Views
    545

    Then it is a "practical" rounding, as in high...

    Then it is a "practical" rounding, as in high school?
    -0.001 is closer to 0.00 or -0.01?
  20. Replies
    11
    Views
    545

    You didn't read, did you? Floating point isn't...

    You didn't read, did you? Floating point isn't decimal!
  21. Replies
    11
    Views
    545

    You do realize floating point is not "decimal"...

    You do realize floating point is not "decimal" and not accurate enough to represent 0.001, don't you?

    Floating point is a fractional representation using 3 unsigned integer values: S, F and E,...
  22. Thread: DD to DMS

    by flp1969
    Replies
    5
    Views
    552

    float has 24 bits of precision, not 25... But you...

    float has 24 bits of precision, not 25... But you can use double (53 bits). In an Intel or ARM processor there's no difference in performance (only double has "double" the size, in comparison with...
  23. Ahhh... and this works very well: int...

    Ahhh... and this works very well:

    int lessThan( int a, int b )
    { return (a - b) >> ( sizeof(int) * CHAR_BIT - 1 ); }
    Right shift with signed integers are "dependent of implementation",...
  24. Well... no '

    Well... no '<' operator here (hehe)...

    // Intel/AMD:
    int lessThan(int a, int b)
    {
    int r = 0;

    __asm__ __volatile__ (
    "cmpl %2,%1\n\t"
    "sets %b0"
  25. Hummmm.... interesting. Thanks.

    Hummmm.... interesting. Thanks.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4