Skip to main content
Add language tag for syntax highlighting
Source Link
Paul R
  • 2.9k
  • 1
  • 18
  • 22

C

float one(void)
{
    const int n = 24; // magic number
    float x = 0.5f;
    float y = x;
    int i;

    for (i = 0; i < n; ++i)
    {
        x *= 0.5f;
        y += x;
    }
    return y;
}
float one(void)
{
    const int n = 24; // magic number
    float x = 0.5f;
    float y = x;
    int i;

    for (i = 0; i < n; ++i)
    {
        x *= 0.5f;
        y += x;
    }
    return y;
}

C

float one(void)
{
    const int n = 24; // magic number
    float x = 0.5f;
    float y = x;
    int i;

    for (i = 0; i < n; ++i)
    {
        x *= 0.5f;
        y += x;
    }
    return y;
}

C

float one(void)
{
    const int n = 24; // magic number
    float x = 0.5f;
    float y = x;
    int i;

    for (i = 0; i < n; ++i)
    {
        x *= 0.5f;
        y += x;
    }
    return y;
}
Source Link
Paul R
  • 2.9k
  • 1
  • 18
  • 22

C

float one(void)
{
    const int n = 24; // magic number
    float x = 0.5f;
    float y = x;
    int i;

    for (i = 0; i < n; ++i)
    {
        x *= 0.5f;
        y += x;
    }
    return y;
}