array shifter
#11
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
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);
}

[Image: Runden-in-QB64-C-2022-09-22.jpg]
Reply


Messages In This Thread
array shifter - by Jack - 09-21-2022, 11:23 PM
RE: array shifter - by Pete - 09-22-2022, 12:39 AM
RE: array shifter - by Jack - 09-22-2022, 12:59 AM
RE: array shifter - by bplus - 09-22-2022, 01:10 AM
RE: array shifter - by Jack - 09-22-2022, 01:15 AM
RE: array shifter - by bplus - 09-22-2022, 01:34 AM
RE: array shifter - by Jack - 09-22-2022, 01:40 AM
RE: array shifter - by Pete - 09-22-2022, 06:17 AM
RE: array shifter - by bplus - 09-22-2022, 02:54 PM
RE: array shifter - by Pete - 09-22-2022, 04:25 PM
RE: array shifter - by Kernelpanic - 09-22-2022, 09:05 PM
RE: array shifter - by Jack - 09-23-2022, 03:10 AM
RE: array shifter - by SpriggsySpriggs - 09-23-2022, 02:56 PM
RE: array shifter - by Pete - 09-23-2022, 03:56 PM
RE: array shifter - by Jack - 09-23-2022, 04:57 PM
RE: array shifter - by Pete - 09-23-2022, 05:04 PM



Users browsing this thread: 11 Guest(s)