ChrisOS Research ProjectOperating systems · language systems · graphics · machine emulation
DOCUMENTATION ARCHIVEMAIN BRANCH
ChrisOS/Referência de fonte: LIB/MATH.CC

Referência de fonte: LIB/MATH.CC

Registro determinístico da fonte. O conteúdo completo do arquivo é reproduzido abaixo; esta página não substitui a interpretação arquitetural dos capítulos autorais.

Identidade do arquivo

Campo Valor
Path LIB/MATH.CC
Lines 65
Bytes 1011
SHA-256 9b5df9c50730b98d417021840be072a72302ba94522ccef31a806adab8435494
ChrisOS revision da3df29cb397932c43d32373871fb9380e688ade

Dependências sintáticas detectadas

Linha Include
1 LIB/MATH.H

Símbolos detectados

Linha Símbolo
3 fabsf
8 fabs
12 tan
24 atan
50 sqrt

Fonte completa

O bloco seguinte é o arquivo textual integral na revisão indicada. Não há elisão, abreviação ou paráfrase.

#include "LIB/MATH.H"

float fabsf(float x) {
    if (x < 0.0) return -x;
    return x;
}

float fabs(float x) {
    return fabsf(x);
}

float tan(float x) {
    float c;
    c = cos(x);
    if (c < 0.0001 && c > -0.0001) {
        if (c < 0.0)
            c = -0.0001;
        else
            c = 0.0001;
    }
    return sin(x) / c;
}

float atan(float x) {
    int sign;
    int inv;
    float z;
    float z2;
    float r;
    sign = 0;
    inv = 0;
    if (x < 0.0) {
        sign = 1;
        x = -x;
    }
    if (x > 1.0) {
        inv = 1;
        x = 1.0 / x;
    }
    z = x;
    z2 = z * z;
    r = z * (1.0 + z2 * (-0.3333333 + z2 * (0.2 + z2 * (-0.142857 + z2 * 0.10186))));
    if (inv)
        r = 1.57079633 - r;
    if (sign)
        r = -r;
    return r;
}

float sqrt(float x) {
    float g;
    int i;
    if (x <= 0.0)
        return 0.0;
    g = x;
    if (g < 1.0)
        g = 1.0;
    i = 0;
    while (i < 12) {
        g = 0.5 * (g + x / g);
        i = i + 1;
    }
    return g;
}

Papel deste registro

O atlas garante rastreabilidade arquivo-a-arquivo. Responsabilidade, invariantes, ownership, concorrência, segurança, desempenho e interação entre subsistemas pertencem aos capítulos autorais e devem citar este arquivo quando aplicável.

Registro do documento ID: source-9b5df9c50730b98d Reviewed source: da3df29cb397 Class: generated-source-reference