Commit 30ccaa11 authored by Over_score's avatar Over_score

Merge branch '336-implement-round-and-roundi' into 'master'

Resolve "Implement ROUND, ROUNDI, RAN#, and SEED"

Closes #336

See merge request !493
parents 762f96ae 192346f2
No preview for this file type
......@@ -76,8 +76,8 @@ SRC_WP43S = \
cxToRe.c idiv.c idivr.c \
division.c exp.c expt.c factorial.c floor.c fractionalPart.c gamma.c gcd.c \
imaginaryPart.c integerPart.c invert.c lcm.c ln.c log10.c \
log2.c magnitude.c mant.c minusOnePow.c modulo.c multiplication.c parallel.c power.c \
realPart.c remainder.c reToCx.c sign.c sin.c sinh.c slvq.c square.c squareRoot.c \
log2.c magnitude.c mant.c minusOnePow.c modulo.c multiplication.c parallel.c pcg_basic.c power.c \
random.c realPart.c remainder.c reToCx.c round.c roundi.c sign.c sin.c sinh.c slvq.c square.c squareRoot.c \
subtraction.c swapRealImaginary.c tan.c tanh.c toPolar.c toRect.c unitVector.c \
wp34s.c) \
$(addprefix src/wp43s/logicalOps/, \
......
......@@ -146,6 +146,7 @@ bool_t displayRealAsFraction;
bool_t savedStackLiftEnabled;
bool_t rbr1stDigit;
bool_t nimInputIsReal34;
bool_t updateDisplayValueX;
calcKey_t kbd_usr[37];
calcRegister_t errorMessageRegisterLine;
calcRegister_t errorRegisterLine;
......@@ -154,6 +155,7 @@ uint64_t shortIntegerMask;
uint64_t shortIntegerSignBit;
glyph_t glyphNotFound = {.charCode = 0x0000, .colsBeforeGlyph = 0, .colsGlyph = 13, .colsAfterGlyph = 0, .rowsGlyph = 19};
char transitionSystemOperation[4];
char displayValueX[80];
int16_t exponentSignLocation;
int16_t denominatorLocation;
int16_t imaginaryExponentSignLocation;
......@@ -167,6 +169,7 @@ real39_t const *gammaConstants;
real39_t const *angle180;
real39_t const *angle90;
real39_t const *angle45;
pcg32_random_t pcg32_global = PCG32_INITIALIZER;
#ifdef DMCP_BUILD
bool_t endOfProgram;
uint32_t nextScreenRefresh; // timer substitute for refreshScreen(), which does cursor blinking and other stuff
......
......@@ -563,6 +563,7 @@ void generateAllConstants(void) {
generateConstantArray("9999", "+9.999000000000000000000000000000000000000000000000000000e+03");
generateConstantArray("10000", "+1.000000000000000000000000000000000000000000000000000000e+04");
generateConstantArray("1e6", "+1.000000000000000000000000000000000000000000000000000000e+06");
generateConstantArray("1e8", "+1.000000000000000000000000000000000000000000000000000000e+08");
generateConstantArray("2p32", "+4.294967296000000000000000000000000000000000000000000000e+09");
generateConstantArray459("2pi", "+6.2831853071795864769252867665590057683943387987502116419498891846156328125724179972560696506842341359"
......
......@@ -10,25 +10,25 @@ Func: fnCxToRe
; Think of the 2 modes: rectangular and polar! And all error situations
;=======================================
; CxToRe(Complex16) --> Real16, Real16
;=======================================
In: SL=0 FI=1 RX=Co16:"42i23" CM=RECT
In: SL=0 FI=1 NCSD=16 RX=Co16:"42 i 23" CM=RECT
Out: EC=0 FI=1 SL=1 RX=Re16:"23" RY=Re16:"42"
In: SL=0 FI=1 RX=Co16:"38.66120384500249i16.41070739654950" CM=POLAR AM=DEG
Out: EC=0 FI=1 SL=1 RX=Re16:"23.00000000000001":DEG RY=Re16:"42"
In: SL=0 FI=1 RX=Co16:"38.66120384500249 i 16.41070739654950" CM=POLAR AM=DEG
;Out: EC=0 FI=1 SL=1 RX=Re16:"23.0000000000000048715862123478998228266333581899923606135896254674":DEG RY=Re16:"41.999999999999997441245881624405874437825734475429105967668082785"
Out: EC=0 FI=1 SL=1 RX=Re16:"23.00000000000001":DEG RY=Re16:"41.999999999999997441245881624405874437825734475429105967668082785"
;=======================================
; CxToRe(Complex34) --> Real34, Real34
;=======================================
In: SL=0 FI=1 RX=Co34:"42i23" RY=LonI:"0" CM=RECT
In: SL=0 FI=1 NCSD=34 RX=Co34:"42 i 23" RY=LonI:"0" CM=RECT
Out: EC=0 FI=1 SL=1 RX=Re34:"23" RY=Re34:"42"
In: SL=0 FI=1 RX=Co34:"38.66120384500249375066957837861938i16.41070739654949771260755273334196" CM=POLAR AM=DEG
Out: EC=0 FI=1 SL=1 RX=Re34:"23":DEG RY=Re34:"42"
In: SL=0 FI=1 RX=Co34:"38.66120384500249375066957837861938 i 16.41070739654949771260755273334196" CM=POLAR AM=DEG
Out: EC=0 FI=1 SL=1 RX=Re34:"23.0000000000000000000000000000000007687828257168522195871481391539":DEG RY=Re34:"42.0000000000000000000000000000000006175484148327838914827403000979"
;=======================================
......
......@@ -10,25 +10,24 @@ Func: fnReToCx
; Think of the 2 modes: rectangular and polar! And all error situations
;=======================================
; ReToCx(Long Integer, Long Integer) --> Complex16
;=======================================
In: SL=0 FI=0 RX=LonI:"23" RY=LonI:"42" RZ=LonI:"0" CM=RECT
Out: EC=0 FI=1 SL=1 RX=Co16:"42i23" RY=LonI:"0"
In: SL=0 FI=0 NCSD=16 RX=LonI:"23" RY=LonI:"42" RZ=LonI:"0" CM=RECT
Out: EC=0 FI=1 SL=1 RX=Co16:"42 i 23" RY=LonI:"0"
In: SL=0 FI=0 RX=LonI:"23" RY=LonI:"42" RZ=LonI:"0" CM=POLAR AM=DEG
Out: EC=0 FI=1 SL=1 RX=Co16:"38.66120384500249i16.41070739654950" RY=LonI:"0"
Out: EC=0 FI=1 SL=1 RX=Co16:"38.6612038450024937506695783786193796517391378007500926530334718949 i 16.4107073965494977126075527333419592399566370382101471813784750775" RY=LonI:"0"
;=======================================
; ReToCx(Long Integer, Real16) --> Complex16
;=======================================
In: SL=0 FI=0 RX=LonI:"23" RY=Re16:"42" RZ=LonI:"0" CM=RECT
In: SL=0 FI=0 NCSD=16 RX=LonI:"23" RY=Re16:"42" RZ=LonI:"0" CM=RECT
Out: EC=0 FI=1 SL=1 RX=Co16:"42i23" RY=LonI:"0"
In: SL=0 FI=0 RX=LonI:"23" RY=Re16:"42" RZ=LonI:"0" CM=POLAR AM=DEG
Out: EC=0 FI=1 SL=1 RX=Co16:"38.66120384500249i16.41070739654950" RY=LonI:"0"
Out: EC=0 FI=1 SL=1 RX=Co16:"38.6612038450024937506695783786193796517391378007500926530334718949 i 16.4107073965494977126075527333419592399566370382101471813784750775" RY=LonI:"0"
......@@ -46,33 +45,33 @@ Out: EC=24 FI=0 SL=0 RX=LonI:"23" RY=ShoI:"42#8"
;=======================================
; ReToCx(Long Integer, Real34) --> Complex34
;=======================================
In: SL=0 FI=0 RX=LonI:"23" RY=Re34:"42" RZ=LonI:"0" CM=RECT
In: SL=0 FI=0 NCSD=34 RX=LonI:"23" RY=Re34:"42" RZ=LonI:"0" CM=RECT
Out: EC=0 FI=1 SL=1 RX=Co34:"42i23" RY=LonI:"0"
In: SL=0 FI=0 RX=LonI:"23" RY=Re34:"42" RZ=LonI:"0" CM=POLAR AM=DEG
Out: EC=0 FI=1 SL=1 RX=Co34:"38.66120384500249375066957837861938i16.41070739654949771260755273334196" RY=LonI:"0"
Out: EC=0 FI=1 SL=1 RX=Co34:"38.6612038450024937506695783786193796517391378007500926530334718949 i 16.4107073965494977126075527333419592399566370382101471813784750775" RY=LonI:"0"
;=======================================
; ReToCx(Real16, Long Integer) --> Complex16
;=======================================
In: SL=0 FI=0 RX=Re16:"23" RY=LonI:"42" RZ=LonI:"0" CM=RECT
In: SL=0 FI=0 NCSD=16 RX=Re16:"23" RY=LonI:"42" RZ=LonI:"0" CM=RECT
Out: EC=0 FI=1 SL=1 RX=Co16:"42i23" RY=LonI:"0"
In: SL=0 FI=0 RX=Re16:"23" RY=LonI:"42" RZ=LonI:"0" CM=POLAR AM=DEG
Out: EC=0 FI=1 SL=1 RX=Co16:"38.66120384500249i16.41070739654950" RY=LonI:"0"
Out: EC=0 FI=1 SL=1 RX=Co16:"38.6612038450024937506695783786193796517391378007500926530334718949 i 16.4107073965494977126075527333419592399566370382101471813784750775" RY=LonI:"0"
;=======================================
; ReToCx(Real16, Real16) --> Complex16
;=======================================
In: SL=0 FI=0 RX=Re16:"23" RY=Re16:"42" RZ=LonI:"0" CM=RECT
In: SL=0 FI=0 NCSD=16 RX=Re16:"23" RY=Re16:"42" RZ=LonI:"0" CM=RECT
Out: EC=0 FI=1 SL=1 RX=Co16:"42i23" RY=LonI:"0"
In: SL=0 FI=0 RX=Re16:"23" RY=Re16:"42" RZ=LonI:"0" CM=POLAR AM=DEG
Out: EC=0 FI=1 SL=1 RX=Co16:"38.66120384500249i16.41070739654950" RY=LonI:"0"
Out: EC=0 FI=1 SL=1 RX=Co16:"38.6612038450024937506695783786193796517391378007500926530334718949 i 16.4107073965494977126075527333419592399566370382101471813784750775" RY=LonI:"0"
......@@ -90,11 +89,11 @@ Out: EC=24 FI=0 SL=0 RX=Re16:"23" RY=ShoI:"42#8"
;=======================================
; ReToCx(Real16, Real34) --> Complex34
;=======================================
In: SL=0 FI=0 RX=Re16:"23" RY=Re34:"42" RZ=LonI:"0" CM=RECT
In: SL=0 FI=0 NCSD=34 RX=Re16:"23" RY=Re34:"42" RZ=LonI:"0" CM=RECT
Out: EC=0 FI=1 SL=1 RX=Co34:"42i23" RY=LonI:"0"
In: SL=0 FI=0 RX=Re16:"23" RY=Re34:"42" RZ=LonI:"0" CM=POLAR AM=DEG
Out: EC=0 FI=1 SL=1 RX=Co34:"38.66120384500249375066957837861938i16.41070739654949771260755273334196" RY=LonI:"0"
Out: EC=0 FI=1 SL=1 RX=Co34:"38.6612038450024937506695783786193796517391378007500926530334718949 i 16.4107073965494977126075527333419592399566370382101471813784750775" RY=LonI:"0"
......@@ -145,22 +144,22 @@ Out: EC=24 FI=0 SL=0 RX=ShoI:"23#8" RY=Re34:"42"
;=======================================
; ReToCx(Real34, Long Integer) --> Complex34
;=======================================
In: SL=0 FI=0 RX=Re34:"23" RY=LonI:"42" RZ=LonI:"0" CM=RECT
In: SL=0 FI=0 NCSD=34 RX=Re34:"23" RY=LonI:"42" RZ=LonI:"0" CM=RECT
Out: EC=0 FI=1 SL=1 RX=Co34:"42i23" RY=LonI:"0"
In: SL=0 FI=0 RX=Re34:"23" RY=LonI:"42" RZ=LonI:"0" CM=POLAR AM=DEG
Out: EC=0 FI=1 SL=1 RX=Co34:"38.66120384500249375066957837861938i16.41070739654949771260755273334196" RY=LonI:"0"
Out: EC=0 FI=1 SL=1 RX=Co34:"38.6612038450024937506695783786193796517391378007500926530334718949 i 16.4107073965494977126075527333419592399566370382101471813784750775" RY=LonI:"0"
;=======================================
; ReToCx(Real34, Real16) --> Complex34
;=======================================
In: SL=0 FI=0 RX=Re34:"23" RY=Re16:"42" RZ=LonI:"0" CM=RECT
In: SL=0 FI=0 NCSD=34 RX=Re34:"23" RY=Re16:"42" RZ=LonI:"0" CM=RECT
Out: EC=0 FI=1 SL=1 RX=Co34:"42i23" RY=LonI:"0"
In: SL=0 FI=0 RX=Re34:"23" RY=Re16:"42" RZ=LonI:"0" CM=POLAR AM=DEG
Out: EC=0 FI=1 SL=1 RX=Co34:"38.66120384500249375066957837861938i16.41070739654949771260755273334196" RY=LonI:"0"
Out: EC=0 FI=1 SL=1 RX=Co34:"38.6612038450024937506695783786193796517391378007500926530334718949 i 16.4107073965494977126075527333419592399566370382101471813784750775" RY=LonI:"0"
......@@ -178,8 +177,8 @@ Out: EC=24 FI=0 SL=0 RX=Re34:"23" RY=ShoI:"42#8"
;=======================================
; ReToCx(Real34, Real34) --> Complex34
;=======================================
In: SL=0 FI=0 RX=Re34:"23" RY=Re34:"42" RZ=LonI:"0" CM=RECT
In: SL=0 FI=0 NCSD=34 RX=Re34:"23" RY=Re34:"42" RZ=LonI:"0" CM=RECT
Out: EC=0 FI=1 SL=1 RX=Co34:"42i23" RY=LonI:"0"
In: SL=0 FI=0 RX=Re34:"23" RY=Re34:"42" RZ=LonI:"0" CM=POLAR AM=DEG
Out: EC=0 FI=1 SL=1 RX=Co34:"38.66120384500249375066957837861938i16.41070739654949771260755273334196" RY=LonI:"0"
Out: EC=0 FI=1 SL=1 RX=Co34:"38.6612038450024937506695783786193796517391378007500926530334718949 i 16.4107073965494977126075527333419592399566370382101471813784750775" RY=LonI:"0"
;*************************************************************
;*************************************************************
;** **
;** round **
;** **
;*************************************************************
;*************************************************************
In: FD=0 FI=0 SD=0 RM=0 IM=2compl SS=4 WS=64
Func: fnRound
;=======================================
; round(Long Integer) --> Real16
;=======================================
In: AM=DEG SL=0 FI=0 NCSD=16 RX=LonI:"12345678901234567"
Out: EC=0 FI=0 SL=1 RL=LonI:"12345678901234567" RX=Re16:"1.234567890123457"
In: AM=DEG SL=0 FI=0 NCSD=16 RX=LonI:"-52"
Out: EC=0 FI=0 SL=1 RL=LonI:"-52" RX=Re16:"-5.2"
In: AM=DEG SL=0 FI=0 NCSD=16 RX=LonI:"0"
Out: EC=0 FI=0 SL=1 RL=LonI:"0" RX=Re16:"0"
;=======================================
; round(Real16) --> Real16
;=======================================
In: AM=DEG SL=0 FI=0 NCSD=16 RX=Re16:"0.0001"
Out: EC=0 FI=0 SL=1 RL=Re16:"0.0001" RX=Re16:"1"
In: AM=GRAD SL=0 FI=0 RX=Re16:"50"
Out: EC=0 FI=0 SL=1 RL=Re16:"50" RX=Re16:"5"
In: AM=MULTPI SL=0 FI=0 RX=Re16:"5.678910111213e234"
Out: EC=0 FI=0 SL=1 RL=Re16:"5.678910111213e234" RX=Re16:"5.678910111213"
In: AM=DEG SL=0 FI=0 RX=Re16:"89.999999999"
Out: EC=0 FI=0 SL=1 RL=Re16:"89.999999999" RX=Re16:"8.9999999999"
;In: SL=0 FI=0 NCSD=16 RX=Re16:"5.32564":DMS
;Out: EC=0 FI=0 SL=1 RL=Re16:"5.32564":DMS RX=Re16:"5.32564"
In: SL=0 FI=0 RX=Re16:"-5.32564":GRAD
Out: EC=0 FI=0 SL=1 RL=Re16:"-5.32564":GRAD RX=Re16:"-5.32564"
In: SL=0 FI=0 RX=Re16:"45":DEG
Out: EC=0 FI=0 SL=1 RL=Re16:"45":DEG RX=Re16:"4.5"
; NaN
In: SL=0 FI=0 RX=Re16:"NaN":RAD
Out: EC=1 FI=0 SL=0 RX=Re16:"NaN":RAD
; Infinity
In: SL=0 FI=0 FD=1 RX=Re16:"inf":DEG
Out: EC=0 FI=0 SL=1 RL=Re16:"inf":DEG RX=Re16:"inf"
In: SL=0 FI=0 FD=0 RX=Re16:"inf":MULTPI
Out: EC=4 FI=0 SL=0 RX=Re16:"inf":MULTPI
In: SL=0 FI=0 FD=0 RX=Re16:"-inf":RAD
Out: EC=5 FI=0 SL=0 RX=Re16:"-inf":RAD
; NaN
In: SL=0 FI=0 RX=Re16:"NaN"
Out: EC=1 FI=0 SL=0 RX=Re16:"NaN"
; Infinity
In: SL=0 FI=0 FD=1 RX=Re16:"inf"
Out: EC=0 FI=0 SL=1 RL=Re16:"inf" RX=Re16:"inf"
In: SL=0 FI=0 FD=0 RX=Re16:"inf"
Out: EC=4 FI=0 SL=0 RX=Re16:"inf"
In: SL=0 FI=0 FD=0 RX=Re16:"-inf"
Out: EC=5 FI=0 SL=0 RX=Re16:"-inf"
;=======================================
; round(Complex16) --> Error24
;=======================================
In: AM=DEG SL=0 FI=0 NCSD=16 RX=Co16:"6.2 i -7.6"
Out: EC=24 FI=0 SL=0 RX=Co16:"6.2 i -7.6"
;=======================================
; round(Time) --> Error24
;=======================================
;=======================================
; round(Date) --> Error24
;=======================================
;=======================================
; round(String) --> Error24
;=======================================
In: SL=0 RX=Stri:"String test"
Out: EC=24 SL=0 RX=Stri:"String test"
;=======================================
; round(Real16 Matrix) --> Error24
;=======================================
;=======================================
; round(Complex16 Matrix) --> Error24
;=======================================
;=======================================
; round(Short Integer) --> Error24
;=======================================
In: SL=0 FI=0 RX=ShoI:"5#7"
Out: EC=24 FI=0 SL=0 RX=ShoI:"5#7"
;=======================================
; round(Real34) --> Real34
;=======================================
In: AM=DEG SL=0 FI=0 NCSD=34 RX=Re34:"0.0001"
Out: EC=0 FI=0 SL=1 RL=Re34:"0.0001" RX=Re34:"1"
In: AM=GRAD SL=0 FI=0 RX=Re34:"50"
Out: EC=0 FI=0 SL=1 RL=Re34:"50" RX=Re34:"5"
In: AM=MULTPI SL=0 FI=0 RX=Re34:"5.6789101112131415161718e234"
Out: EC=0 FI=0 SL=1 RL=Re34:"5.6789101112131415161718e234" RX=Re34:"5.6789101112131415161718"
In: AM=DEG SL=0 FI=0 RX=Re34:"89.999999999"
Out: EC=0 FI=0 SL=1 RL=Re34:"89.999999999" RX=Re34:"8.9999999999"
;In: SL=0 FI=0 NCSD=34 RX=Re34:"5.32564":DMS
;Out: EC=0 FI=0 SL=1 RL=Re34:"5.32564":DMS RX=Re34:"5.32564"
In: SL=0 FI=0 RX=Re34:"-5.32564":GRAD
Out: EC=0 FI=0 SL=1 RL=Re34:"-5.32564":GRAD RX=Re34:"-5.32564"
In: SL=0 FI=0 RX=Re34:"45":DEG
Out: EC=0 FI=0 SL=1 RL=Re34:"45":DEG RX=Re34:"4.5"
; NaN
In: SL=0 FI=0 RX=Re34:"NaN":RAD
Out: EC=1 FI=0 SL=0 RX=Re34:"NaN":RAD
; Infinity
In: SL=0 FI=0 FD=1 RX=Re34:"inf":DEG
Out: EC=0 FI=0 SL=1 RL=Re34:"inf":DEG RX=Re34:"inf"
In: SL=0 FI=0 FD=0 RX=Re34:"inf":MULTPI
Out: EC=4 FI=0 SL=0 RX=Re34:"inf":MULTPI
In: SL=0 FI=0 FD=0 RX=Re34:"-inf":RAD
Out: EC=5 FI=0 SL=0 RX=Re34:"-inf":RAD
; NaN
In: SL=0 FI=0 RX=Re34:"NaN"
Out: EC=1 FI=0 SL=0 RX=Re34:"NaN"
; Infinity
In: SL=0 FI=0 FD=1 RX=Re34:"inf"
Out: EC=0 FI=0 SL=1 RL=Re34:"inf" RX=Re34:"inf"
In: SL=0 FI=0 FD=0 RX=Re34:"inf"
Out: EC=4 FI=0 SL=0 RX=Re34:"inf"
In: SL=0 FI=0 FD=0 RX=Re34:"-inf"
Out: EC=5 FI=0 SL=0 RX=Re34:"-inf"
;=======================================
; round(Complex34) --> Error24
;=======================================
In: AM=DEG SL=0 FI=0 NCSD=34 RX=Co34:"6.2 i -7.6"
Out: EC=24 FI=0 SL=0 RX=Co34:"6.2 i -7.6"
;*************************************************************
;*************************************************************
;** **
;** roundi **
;** **
;*************************************************************
;*************************************************************
In: FD=0 FI=0 SD=0 RM=0 IM=2compl SS=4 WS=64
Func: fnRoundi
;=======================================
; roundi(Long Integer) --> Real16
;=======================================
In: AM=DEG SL=0 FI=0 NCSD=16 RX=LonI:"12345678901234567"
Out: EC=24 FI=0 SL=0 RX=LonI:"12345678901234567"
;=======================================
; roundi(Real16) --> Real16
;=======================================
In: AM=DEG SL=0 FI=0 NCSD=16 RX=Re16:"0.0001"
Out: EC=0 FI=0 SL=1 RL=Re16:"0.0001" RX=LonI:"0"
In: AM=GRAD SL=0 FI=0 RX=Re16:"50.7"
Out: EC=0 FI=0 SL=1 RL=Re16:"50.7" RX=LonI:"51"
In: AM=MULTPI SL=0 FI=0 RX=Re16:"5.678910111213e50"
Out: EC=0 FI=0 SL=1 RL=Re16:"5.678910111213e50" RX=LonI:"567891011121300000000000000000000000000000000000000"
In: AM=DEG SL=0 FI=0 RX=Re16:"89.999999999"
Out: EC=0 FI=0 SL=1 RL=Re16:"89.999999999" RX=LonI:"90"
In: SL=0 FI=0 NCSD=16 RX=Re16:"-5.32564":DMS
Out: EC=0 FI=0 SL=1 RL=Re16:"-5.32564":DMS RX=LonI:"-5"
In: SL=0 FI=0 RX=Re16:"-5.72564":GRAD
Out: EC=0 FI=0 SL=1 RL=Re16:"-5.72564":GRAD RX=LonI:"-6"
In: SL=0 FI=0 RX=Re16:"45":DEG
Out: EC=0 FI=0 SL=1 RL=Re16:"45":DEG RX=LonI:"45"
; NaN
In: SL=0 FI=0 RX=Re16:"NaN":RAD
Out: EC=1 FI=0 SL=0 RX=Re16:"NaN":RAD
In: SL=0 FI=0 RX=Re16:"NaN"
Out: EC=1 FI=0 SL=0 RX=Re16:"NaN"
; Infinity
In: SL=0 FI=0 FD=1 RX=Re16:"inf":DEG
Out: EC=1 FI=0 SL=0 RX=Re16:"inf":DEG
In: SL=0 FI=0 FD=0 RX=Re16:"-inf":RAD
Out: EC=1 FI=0 SL=0 RX=Re16:"-inf":RAD
In: SL=0 FI=0 FD=1 RX=Re16:"inf"
Out: EC=1 FI=0 SL=0 RX=Re16:"inf"
In: SL=0 FI=0 FD=0 RX=Re16:"-inf"
Out: EC=1 FI=0 SL=0 RX=Re16:"-inf"
;=======================================
; roundi(Complex16) --> Error24
;=======================================
In: AM=DEG SL=0 FI=0 NCSD=16 RX=Co16:"6.2 i -7.6"
Out: EC=24 FI=0 SL=0 RX=Co16:"6.2 i -7.6"
;=======================================
; roundi(Time) --> Error24
;=======================================
;=======================================
; roundi(Date) --> Error24
;=======================================
;=======================================
; roundi(String) --> Error24
;=======================================
In: SL=0 RX=Stri:"String test"
Out: EC=24 SL=0 RX=Stri:"String test"
;=======================================
; roundi(Real16 Matrix) --> Error24
;=======================================
;=======================================
; roundi(Complex16 Matrix) --> Error24
;=======================================
;=======================================
; roundi(Short Integer) --> Error24
;=======================================
In: SL=0 FI=0 RX=ShoI:"5#7"
Out: EC=24 FI=0 SL=0 RX=ShoI:"5#7"
;=======================================
; roundi(Real34) --> Real34
;=======================================
In: AM=DEG SL=0 FI=0 NCSD=34 RX=Re34:"0.0001"
Out: EC=0 FI=0 SL=1 RL=Re34:"0.0001" RX=LonI:"0"
In: AM=GRAD SL=0 FI=0 RX=Re34:"50.7"
Out: EC=0 FI=0 SL=1 RL=Re34:"50.7" RX=LonI:"51"
In: AM=MULTPI SL=0 FI=0 RX=Re34:"5.678910111213e50"
Out: EC=0 FI=0 SL=1 RL=Re34:"5.678910111213e50" RX=LonI:"567891011121300000000000000000000000000000000000000"
In: AM=DEG SL=0 FI=0 RX=Re34:"89.999999999"
Out: EC=0 FI=0 SL=1 RL=Re34:"89.999999999" RX=LonI:"90"
In: SL=0 FI=0 NCSD=34 RX=Re34:"-5.32564":DMS
Out: EC=0 FI=0 SL=1 RL=Re34:"-5.32564":DMS RX=LonI:"-5"
In: SL=0 FI=0 RX=Re34:"-5.72564":GRAD
Out: EC=0 FI=0 SL=1 RL=Re34:"-5.72564":GRAD RX=LonI:"-6"
In: SL=0 FI=0 RX=Re34:"45":DEG
Out: EC=0 FI=0 SL=1 RL=Re34:"45":DEG RX=LonI:"45"
; NaN
In: SL=0 FI=0 RX=Re34:"NaN":RAD
Out: EC=1 FI=0 SL=0 RX=Re34:"NaN":RAD
In: SL=0 FI=0 RX=Re34:"NaN"
Out: EC=1 FI=0 SL=0 RX=Re34:"NaN"
; Infinity
In: SL=0 FI=0 FD=1 RX=Re34:"inf":DEG
Out: EC=1 FI=0 SL=0 RX=Re34:"inf":DEG
In: SL=0 FI=0 FD=0 RX=Re34:"-inf":RAD
Out: EC=1 FI=0 SL=0 RX=Re34:"-inf":RAD
In: SL=0 FI=0 FD=1 RX=Re34:"inf"
Out: EC=1 FI=0 SL=0 RX=Re34:"inf"
In: SL=0 FI=0 FD=0 RX=Re34:"-inf"
Out: EC=1 FI=0 SL=0 RX=Re34:"-inf"
;=======================================
; roundi(Complex34) --> Error24
;=======================================
In: AM=DEG SL=0 FI=0 NCSD=34 RX=Co34:"6.2 i -7.6"
Out: EC=24 FI=0 SL=0 RX=Co34:"6.2 i -7.6"
This diff is collapsed.
......@@ -26,7 +26,7 @@ extern const int16_t menu_FCNS[];
extern const int16_t menu_CNST[];
extern const int16_t menu_MENUS[];
extern const softmenu_t softmenu[];
char line[10000], lastInParameters[10000], fileName[1000], filePath[1000], filePathName[2000], registerExpectedAndValue[1000];
char line[100000], lastInParameters[10000], fileName[1000], filePath[1000], filePathName[2000], registerExpectedAndValue[1000];
int32_t lineNumber, numTestsFile, numTestsTotal;
int32_t functionIndex, funcType, correctSignificantDigits, numberOfCorrectSignificantDigitsExpected;
void (*funcNoParam)(uint16_t);
......@@ -119,6 +119,8 @@ const funcTest_t funcTestNoParam[] = {
{"fnRmd", fnRmd },
{"fnRollDown", fnRollDown },
{"fnRollUp", fnRollUp },
{"fnRound", fnRound },
{"fnRoundi", fnRoundi },
{"fnSign", fnSign },
{"fnSin", fnSin },
{"fnSinh", fnSinh },
......@@ -1012,7 +1014,7 @@ void checkRegisterType(calcRegister_t regist, char letter, uint32_t expectedData
int relativeErrorReal16(real16_t *expectedValue16, real16_t *value16, char *numberPart) {
int relativeErrorReal16(real16_t *expectedValue16, real16_t *value16, char *numberPart, calcRegister_t regist, char letter) {
real39_t expectedValue, value, relativeError, numSignificantDigits;
real16_t integer;
......@@ -1041,7 +1043,12 @@ int relativeErrorReal16(real16_t *expectedValue16, real16_t *value16, char *numb
correctSignificantDigits = real16ToInt32(&integer);
if(correctSignificantDigits <= 16) {
//printf("\nThere are only %d correct significant digits in the %s part of the value: %d are expected!\n", correctSignificantDigits, numberPart, numberOfCorrectSignificantDigitsExpected);
printf("\nThere are only %d correct significant digits in the %s part of the value!\n", correctSignificantDigits, numberPart);
if(letter == 0) {
printf("\nThere are only %d correct significant digits in the %s part of register %d!\n", correctSignificantDigits, numberPart, regist);
}
else {
printf("\nThere are only %d correct significant digits in the %s part of register %c!\n", correctSignificantDigits, numberPart, letter);
}
printf("%s\n", lastInParameters);
printf("%s\n", line);
printf("in file %s line %d\n", fileName, lineNumber);
......@@ -1056,7 +1063,7 @@ int relativeErrorReal16(real16_t *expectedValue16, real16_t *value16, char *numb
int relativeErrorReal34(real34_t *expectedValue34, real34_t *value34, char *numberPart) {
int relativeErrorReal34(real34_t *expectedValue34, real34_t *value34, char *numberPart, calcRegister_t regist, char letter) {
real39_t expectedValue, value, relativeError, numSignificantDigits;
real16_t integer;
......@@ -1085,7 +1092,12 @@ int relativeErrorReal34(real34_t *expectedValue34, real34_t *value34, char *numb
correctSignificantDigits = real16ToInt32(&integer);
if(correctSignificantDigits <= 34) {
//printf("\nThere are only %d correct significant digits in the %s part of the value: %d are expected!\n", correctSignificantDigits, numberPart, numberOfCorrectSignificantDigitsExpected);
printf("\nThere are only %d correct significant digits in the %s part of the value!\n", correctSignificantDigits, numberPart);
if(letter == 0) {
printf("\nThere are only %d correct significant digits in the %s part of register %d!\n", correctSignificantDigits, numberPart, regist);
}
else {
printf("\nThere are only %d correct significant digits in the %s part of register %c!\n", correctSignificantDigits, numberPart, letter);
}
printf("%s\n", lastInParameters);
printf("%s\n", line);
printf("in file %s line %d\n", fileName, lineNumber);
......@@ -1597,7 +1609,7 @@ void checkExpectedOutParameter(char *p) {
strcat(r, " +ix ");
strcat(r, imag);
expectedAndShouldBeValue(regist, letter, r, registerExpectedAndValue);
if(relativeErrorReal16(&expectedReal16, REGISTER_REAL16_DATA(regist), "real") == RE_INACCURATE) {
if(relativeErrorReal16(&expectedReal16, REGISTER_REAL16_DATA(regist), "real", regist, letter) == RE_INACCURATE) {
wrongRegisterValue(regist, letter, r);
}
}
......@@ -1605,7 +1617,7 @@ void checkExpectedOutParameter(char *p) {
strcat(r, " +ix ");
strcat(r, imag);
expectedAndShouldBeValue(regist, letter, r, registerExpectedAndValue);
if(relativeErrorReal16(&expectedImag16, REGISTER_IMAG16_DATA(regist), "imaginary") == RE_INACCURATE) {
if(relativeErrorReal16(&expectedImag16, REGISTER_IMAG16_DATA(regist), "imaginary", regist, letter) == RE_INACCURATE) {
wrongRegisterValue(regist, letter, r);
}
}
......@@ -1649,7 +1661,7 @@ void checkExpectedOutParameter(char *p) {
stringToReal16(r, &expectedReal16);
if(!real16AreEqual(REGISTER_REAL16_DATA(regist), &expectedReal16)) {
expectedAndShouldBeValue(regist, letter, r, registerExpectedAndValue);
if(relativeErrorReal16(&expectedReal16, REGISTER_REAL16_DATA(regist), "real") == RE_INACCURATE) {
if(relativeErrorReal16(&expectedReal16, REGISTER_REAL16_DATA(regist), "real", regist, letter) == RE_INACCURATE) {
wrongRegisterValue(regist, letter, r);
}
}
......@@ -1662,7 +1674,7 @@ void checkExpectedOutParameter(char *p) {
//printf("\n1<%s|%s|%s>\n", p, l, r);
if(!real34AreEqual(REGISTER_REAL34_DATA(regist), &expectedReal34)) {
expectedAndShouldBeValue(regist, letter, r, registerExpectedAndValue);
if(relativeErrorReal34(&expectedReal34, REGISTER_REAL34_DATA(regist), "real") == RE_INACCURATE) {
if(relativeErrorReal34(&expectedReal34, REGISTER_REAL34_DATA(regist), "real", regist, letter) == RE_INACCURATE) {
wrongRegisterValue(regist, letter, r);
}
//printf("\n2<%s|%s|%s>\n", p, l, r);
......@@ -1780,7 +1792,7 @@ void checkExpectedOutParameter(char *p) {
strcat(r, " +ix ");
strcat(r, imag);
expectedAndShouldBeValue(regist, letter, r, registerExpectedAndValue);
if(relativeErrorReal34(&expectedReal34, REGISTER_REAL34_DATA(regist), "real") == RE_INACCURATE) {
if(relativeErrorReal34(&expectedReal34, REGISTER_REAL34_DATA(regist), "real", regist, letter) == RE_INACCURATE) {
wrongRegisterValue(regist, letter, r);
}
}
......@@ -1788,7 +1800,7 @@ void checkExpectedOutParameter(char *p) {
strcat(r, " +ix ");
strcat(r, imag);
expectedAndShouldBeValue(regist, letter, r, registerExpectedAndValue);
if(relativeErrorReal34(&expectedImag34, REGISTER_IMAG34_DATA(regist), "imaginary") == RE_INACCURATE) {
if(relativeErrorReal34(&expectedImag34, REGISTER_IMAG34_DATA(regist), "imaginary", regist, letter) == RE_INACCURATE) {
wrongRegisterValue(regist, letter, r);
}
}
......@@ -1983,6 +1995,18 @@ void standardizeLine(void) {
while(line[0] == ' ') {
memmove(line, line + 1, strlen(line));
}
// 2 spaces ==> 1 space
for(uint32_t i=0; i<strlen(line); i++) {
if(line[i] == '"') {
i = endOfString(line + i) - line;
}
if(line[i] == ' ' && line[i + 1] == ' ') {
memmove(line + i, line + i + 1, strlen(line + i) - 1);
line[strlen(line) - 1] = 0;
i--;
}
}
}
......@@ -2059,6 +2083,14 @@ void processOneFile(void) {
lineNumber = 1;
while(!feof(testSuite)) {
standardizeLine();
while(strlen(line) >= 4 && strncmp(line + strlen(line) - 4, " ...", 4) == 0) {
line[strlen(line) - 3] = 0;
if(!feof(testSuite)) {
fgets(line + strlen(line), 9999, testSuite);
lineNumber++;
standardizeLine();
}
}
processLine();
fgets(line, 9999, testSuite);
lineNumber++;
......
......@@ -46,7 +46,7 @@ void standardizeLine (void);
void processLine (void);
void processOneFile (void);
void processTests (void);
int relativeErrorReal16 (real16_t *expectedValue, real16_t *value, char *numberPart);
int relativeErrorReal34 (real34_t *expectedValue, real34_t *value, char *numberPart);
int relativeErrorReal16 (real16_t *expectedValue, real16_t *value, char *numberPart, calcRegister_t regist, char letter);
int relativeErrorReal34 (real34_t *expectedValue, real34_t *value, char *numberPart, calcRegister_t regist, char letter);
void wrongRegisterValue (calcRegister_t regist, char letter, char *expectedValue);
void expectedAndShouldBeValue (calcRegister_t regist, char letter, char *expectedValue, char *expectedAndValue);
......@@ -36,6 +36,8 @@
; to put a \ or a " in a string use: \\ or \" example: "double quote=\" backslash=\\"
; \x followed by 2 hexadecimal digits inserts the hexadecimal char in the string
;
; ... at the end of a line means the line continues on the following line
;
; All letters can be written upper or lower case but the function names are case sensitive
;
; No space around the equal sign is allowed
......@@ -137,6 +139,8 @@ polarToRectangular.txt
ceil.txt
floor.txt
;round.txt
roundi.txt
idiv.txt
idivr.txt
......
......@@ -985,7 +985,7 @@ void addItemToNimBuffer(int16_t item) {
case NP_REAL_EXPONENT : // +12345.678e+3
nimBufferToDisplayBuffer(nimBuffer, nimBufferDisplay + 2);
exponentToDisplayString(atoi(nimBuffer + exponentSignLocation), nimBufferDisplay + stringByteLength(nimBufferDisplay), true);
exponentToDisplayString(atoi(nimBuffer + exponentSignLocation), nimBufferDisplay + stringByteLength(nimBufferDisplay), NULL, true);
if(nimBuffer[exponentSignLocation + 1] == 0 && nimBuffer[exponentSignLocation] == '-') {
strcat(nimBufferDisplay, STD_SUP_MINUS);
}
......@@ -1001,13 +1001,13 @@ void addItemToNimBuffer(int16_t item) {
strcat(nimBufferDisplay, STD_SPACE_4_PER_EM);
for(index=2; nimBuffer[index]!=' '; index++); // The ending semi colon is OK here
supNumberToDisplayString(atoi(nimBuffer + index + 1), nimBufferDisplay + stringByteLength(nimBufferDisplay), true);