lkml.org 
[lkml]   [1998]   [May]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRE: Draft version of Out-Of-Memory killer
    -----BEGIN PGP SIGNED MESSAGE-----


    On 04-May-98 Rik van Riel wrote:

    > /* Ugly helper function, we don't want to do without it because
    > * the points variable might overflow if we just squared the
    > * size instead. */
    > inline int int_sqrt(int x)
    > {
    > int i,out;
    > for (i = 10; i-- > 0;)
    > out = x + out >> 1;
    > if (out)
    > return out;
    > return 1;
    > }
    >

    Well I do not understand the rest, but if your purpose is to
    evauate the square root of an (unsigned) integer using ten
    iterations of Newton's method, the code could be:

    inline int int_sqrt(int x)
    {
    int i, out=x;

    if (out) {
    for (i = 10; i > 0; i--)
    out = ( out + x/out ) >> 1 ;
    return out;
    }
    return 0;
    }



    - --
    Manuel J. Galan
    manolow@step.es

    -----BEGIN PGP SIGNATURE-----
    Version: PGPfreeware 5.0i for non-commercial use
    Comment: Using RSA Key
    Charset: noconv

    iQEVAwUBNU3ev2D+APAfXUYjAQHFZQf/QqTpZdkvySRNdtQz5H7+Qx1N92KHrvIx
    3PqarzKRA8cchX7GtLneIGkrcYwIuoDGEfGnyhfsnqMcejml3/PrLjHgYXp6amkf
    96ozzlqmBiHV3L5r9TW/ggJkIeolksAlMHJVxL3dYQJlQ4+6vqII+1b7AQVW+D/H
    wz8WTfCBX6g56MJSiT7T2dzEodX8TPjNI0i6clrI+oJrTeocmaFnZHgN5fU3A8rQ
    h6mEzlyH5MXzeIosHK9/2yaQzioWTNLtWimn6lt5ozEZAIHkGcjMn2LxqkifNbfA
    gv1y88vfYtYErHP6QGiceb4a5F16e9zZKSBOFMc9d0prwyg74ngRTg==
    =9G7D
    -----END PGP SIGNATURE-----

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.rutgers.edu

    \
     
     \ /
      Last update: 2005-03-22 13:42    [W:0.026 / U:0.012 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site