1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00

Now in OS/K : floats !

This commit is contained in:
Adrien Bourmault 2019-11-27 00:23:50 +01:00
parent 1d96e30625
commit 4676b84c4c

View File

@ -164,24 +164,26 @@ error_t CmdDumpATASect(int argc, char **argv, char *cmdline)
return EOK;
}
error_t CmdFloat(int argc, char **argv, char *cmdline)
error_t CmdFloatDiv(int argc, char **argv, char *cmdline)
{
double param = (double)ShAtoi(argv[1]);
double a = (double)ShAtoi(argv[1]);
double b = (double)ShAtoi(argv[2]);
double b = 138899.009 / (14.9); //9322,0811409
double number = a / b;
double number_ent = (double)(ulong)number;
double dec = number - number_ent;
double sub = 0.0;
double b_ent = (double)(ulong)b;
double dec = 0.0;
char res[17]; // 10e-16 is the max precision
KernLog("int(b) = %d \n", (ulong)b_ent);
KernLog("dec(b) = ");
for(int i = 0; i < 16; i++) {
dec = (dec * 10.0) - (sub * 10.0);
sub = (double)(ulong)dec;
for(double i = 0; i < param; i++) {
dec = ;
KernLog("%d", (ulong)dec);
snprintf(&res[i], 17-i, "%d", (ulong)dec);
}
KernLog("\n");
KernLog("%d / %d = %d.%s \n", (ulong)a, (ulong)b, (ulong)number_ent, res);
return EOK;
}
@ -362,7 +364,7 @@ static Command_t testcmdtable[] =
{ "help", CmdHelpTest, "Show this message" },
{ "pf", CmdPF, "Provoke a PF. Usage: pfault <address>"},
{ "ps", CmdPsTest, "Scheduler test routine" },
{ "float", CmdFloat, "Float test" },
{ "div", CmdFloatDiv, "Float div. Usage : div a b. Returns a/b"},
{ "rpag", CmdReloadPage, "Reload the pages directory" },
{ "shell", CmdShell, "Start a new shell (nested)", },
{ "stkov", CmdStackOverflow, "Provoke a stack overflow" },