The new Decimal API

This commit is contained in:
Krasimir Angelov
2023-08-21 20:14:26 +02:00
parent 58da8deca8
commit fb398c603e
147 changed files with 918 additions and 188 deletions

View File

@@ -75,6 +75,7 @@ concrete CatLit of Cat = CommonX - [CAdv, Adv] ** open ResLit, Prelude, (R = Par
numAgr:NumComb; nb:Number };
Ord = { s:AForm => Str };
Digits = { s:Str; o:Str; numAgr:NumComb; nb:Number };
Decimal = { s:Str; o:Str; numAgr:NumComb; nb:Number; hasDot : Bool };
---- Structural

View File

@@ -249,6 +249,7 @@ concrete NounLit of Noun = CatLit ** open ResLit, Prelude, MorphoLit, Predef in
-- NumDigits : Digits -> Card ; -- 51
NumDigits n = { s=\\_,_ => n.s; numAgr=n.numAgr; nb=n.nb };
NumDecimal n = { s=\\_,_ => n.s; numAgr=n.numAgr; nb=n.nb };
-- NumCard : Card -> Num ;
NumCard c = c ** { hasCard = True };

View File

@@ -345,4 +345,21 @@ oper simtas : Case * Number => Str
D_8 = { s = "8"; o="8."; nb=Pl; numAgr=AgrComb };
D_9 = { s = "9"; o="9."; nb=Pl; numAgr=AgrComb };
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = "-" ++ BIND ++ d.s;
o = "-" ++ BIND ++ d.o;
nb=Pl;
numAgr=d.numAgr;
hasDot=False
} ;
IFrac d i = {
s = d.s ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s;
nb = Pl ;
numAgr=d.numAgr;
hasDot=True
} ;
}