Now in OS/K : floats !
This commit is contained in:
parent
1d96e30625
commit
4676b84c4c
|
@ -164,24 +164,26 @@ error_t CmdDumpATASect(int argc, char **argv, char *cmdline)
|
||||||
return EOK;
|
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;
|
char res[17]; // 10e-16 is the max precision
|
||||||
double dec = 0.0;
|
|
||||||
|
|
||||||
KernLog("int(b) = %d \n", (ulong)b_ent);
|
for(int i = 0; i < 16; i++) {
|
||||||
KernLog("dec(b) = ");
|
dec = (dec * 10.0) - (sub * 10.0);
|
||||||
|
sub = (double)(ulong)dec;
|
||||||
|
|
||||||
for(double i = 0; i < param; i++) {
|
snprintf(&res[i], 17-i, "%d", (ulong)dec);
|
||||||
dec = ;
|
|
||||||
KernLog("%d", (ulong)dec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KernLog("\n");
|
KernLog("%d / %d = %d.%s \n", (ulong)a, (ulong)b, (ulong)number_ent, res);
|
||||||
|
|
||||||
return EOK;
|
return EOK;
|
||||||
}
|
}
|
||||||
|
@ -362,7 +364,7 @@ static Command_t testcmdtable[] =
|
||||||
{ "help", CmdHelpTest, "Show this message" },
|
{ "help", CmdHelpTest, "Show this message" },
|
||||||
{ "pf", CmdPF, "Provoke a PF. Usage: pfault <address>"},
|
{ "pf", CmdPF, "Provoke a PF. Usage: pfault <address>"},
|
||||||
{ "ps", CmdPsTest, "Scheduler test routine" },
|
{ "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" },
|
{ "rpag", CmdReloadPage, "Reload the pages directory" },
|
||||||
{ "shell", CmdShell, "Start a new shell (nested)", },
|
{ "shell", CmdShell, "Start a new shell (nested)", },
|
||||||
{ "stkov", CmdStackOverflow, "Provoke a stack overflow" },
|
{ "stkov", CmdStackOverflow, "Provoke a stack overflow" },
|
||||||
|
|
Loading…
Reference in New Issue