summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-05-23 09:16:09 +0200
committerErich Eckner <git@eckner.net>2018-05-23 09:16:20 +0200
commitf3e362ad5a6f8f4b79bb2fa209f40d597fb46edc (patch)
treee0713e1579faf369b006fb30c67eb1be5089736b
parent868c9eceed1355f78fa0271b0d67092a2b448d40 (diff)
downloadunits-f3e362ad5a6f8f4b79bb2fa209f40d597fb46edc.tar.xz
matheunit.pas: exprToFloat kennt nun auch "mod"
-rw-r--r--matheunit.pas12
1 files changed, 11 insertions, 1 deletions
diff --git a/matheunit.pas b/matheunit.pas
index 9f615bb..da1a83d 100644
--- a/matheunit.pas
+++ b/matheunit.pas
@@ -534,7 +534,7 @@ var
val1,val2: extended;
const
fkt1: array[0..9] of string = ('exp','sin','cos','tan','sqr','sqrt','ln','round','floor','ceil');
- fkt2: array[0..1] of string = ('min','max');
+ fkt2: array[0..2] of string = ('min','max','mod');
begin
s:=trimAll(s);
@@ -592,6 +592,16 @@ begin
case i of
0: val1:=min(val1,val2);
1: val1:=max(val1,val2);
+ 2:
+ begin
+ if val2<0 then
+ val2:=-val2;
+ assert(val2>0,'Der Modul darf nicht 0 sein.');
+ while val1<0 do
+ val1:=val1+val2;
+ while val1>=val2 do
+ val1:=val1-val2;
+ end;
end{of case};
s:=copy(s,1,k-1) + floattostr(val1) + copy(s,j+1,length(s));
end;