09-22-2022, 09:05 PM
To use this practically you would have to put it in a header file, something like in C. For example: <numeric.h>. And in the program one access it via "_bignumberXY".
But there are also "everyday" problems with decimal numbers. See screenshot: QB64 above, then in C, Win-Calculator, and then in C in Linux (well, it's just the same GCC).
The question is, which result is correct in practice? So the back calculation.
In QB64 - 3.2
In C
But there are also "everyday" problems with decimal numbers. See screenshot: QB64 above, then in C, Win-Calculator, and then in C in Linux (well, it's just the same GCC).
The question is, which result is correct in practice? So the back calculation.
In QB64 - 3.2
Code: (Select All)
Option _Explicit
Declare Function Nte_Wurzel(n As Double, x As Double) As Double
Declare Function Nte_Potenz(n As Double, x As Double) As Double
Dim As Double n, x
Print
Input "Wurzelexponent: ", n
Input "Radikand : ", x
Print
Print Using "Die ###.## Wurzel aus ###.## ist: ##.##########"; n, x, Nte_Wurzel(n, x)
Print: Print
Print "Ueberpruefung: Wurzelwert mit demselben Exponenten potenzieren"
Print
Print Using "Wurzelwert ##.########## potenziert mit Exponent ###.## ergibt: ##.######"; Nte_Wurzel(n, x), n, Nte_Potenz(Nte_Wurzel(n, x), n)
End
Function Nte_Wurzel (n As Double, x As Double)
Dim wurzelx As Double
wurzelx = x ^ (1 / n)
Nte_Wurzel = wurzelx
End Function
Function Nte_Potenz (wurzelx As Double, exponent As Double)
Dim potenz As Double
potenz = wurzelx ^ exponent
Nte_Potenz = potenz
End Function
In C
Code: (Select All)
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double nte_wurzel(double n, double x);
double nte_potenz(double n, double x);
int main(void)
{
double n, x; //n = Wurzelexponent, x = Radikand
printf("\nBerechnung der n-ten Wurzel");
printf("\nWurzelexponent: ");
scanf("%lf", &n);
printf("Radikand : ");
scanf("%lf", &x);
printf("\n\nDie %5.2f Wurzel aus %5.2f = %12.10f", n, x, nte_wurzel(n, x));
printf("\nWurzelwert %12.10f potenziert mit Exponent %5.2f ergibt: %9.6f", nte_wurzel(n, x), n, nte_potenz(nte_wurzel(n, x), n));
return(0);
}
double nte_wurzel(double n, double x)
{
double wurzelx;
wurzelx = pow(x, (1.0 / n));
return(wurzelx);
}
double nte_potenz(double n, double x)
{
double potenz;
potenz = pow(n, x);
return(potenz);
}