From 2c8050d5cb38a51cc49a92304d7ca7d8ec6fec55 Mon Sep 17 00:00:00 2001 From: Peter O Date: Wed, 30 Jun 2021 04:19:34 -0400 Subject: [PATCH] Version 1.8.1 --- Numbers.nuspec | 9 +- Numbers/PeterO/Numbers/RadixMath.cs | 6 +- Numbers/docs.xml | 3 - Numbers20/Properties/AssemblyInfo.cs | 6 +- Numbers40/Properties/AssemblyInfo.cs | 6 +- Test/EDecimalTest.cs | 310 +++++++++++++-------------- Test/EFloatTest.cs | 117 +++++----- docs/PeterO.Numbers.EInteger.md | 29 +-- 8 files changed, 233 insertions(+), 253 deletions(-) diff --git a/Numbers.nuspec b/Numbers.nuspec index 0b60f06..78cb5f5 100644 --- a/Numbers.nuspec +++ b/Numbers.nuspec @@ -1,8 +1,13 @@ 1.8.0PeterO.NumbersfalseVersion 1.8 +>1.8.1PeterO.NumbersfalseVersion 1.8.1 + +- Fix bugs in EFloat string parsing in certain corner cases +- Fix NaN roundtripping with From/ToSingleBits and From/ToDoubleBits + +Version 1.8 - Add LowBits family of methods to EInteger - Add FromInt64AsUnsigned to EInteger, EDecimal, EFloat, and ERational - Add overload to FromBytes method of EInteger - Bug fixesCC0-1.0https://github.com/peteroupc/NumbersPeter OccilA C# library that supports arbitrary-precision binary and decimal floating-point numbers and rational numbers with arbitrary-precision components, and supports arithmetic with these numbers.Peter OccilArbitrary-Precision Number Librarynumbers arithmetic decimal math +> \ No newline at end of file diff --git a/Numbers/PeterO/Numbers/RadixMath.cs b/Numbers/PeterO/Numbers/RadixMath.cs index fc66fcf..b6aa6c6 100644 --- a/Numbers/PeterO/Numbers/RadixMath.cs +++ b/Numbers/PeterO/Numbers/RadixMath.cs @@ -2301,8 +2301,10 @@ internal class RadixMath : IRadixMath { // thisValue is 1 and power is a negative integer, the reciprocal of 1 // is used, which will have an exponent of 0, according to the // General Decimal Arithmetic Specification - return this.PowerIntegral(this.helper.ValueOf(1), signedMant, - ctx); + return this.PowerIntegral( + this.helper.ValueOf(1), + signedMant, + ctx); } else { return this.PowerIntegral(thisValue, signedMant, ctx); } diff --git a/Numbers/docs.xml b/Numbers/docs.xml index 8cb729b..619ad5b 100644 --- a/Numbers/docs.xml +++ b/Numbers/docs.xml @@ -11364,9 +11364,6 @@ "Forms of numbers" ) for the purposes of this operator. - - -The parameter is a Numbers.EInteger object.The return value is not documented yet.The parameter is null. diff --git a/Numbers20/Properties/AssemblyInfo.cs b/Numbers20/Properties/AssemblyInfo.cs index 3ca4188..208cfd2 100644 --- a/Numbers20/Properties/AssemblyInfo.cs +++ b/Numbers20/Properties/AssemblyInfo.cs @@ -1,8 +1,8 @@ using System.Reflection; [assembly: System.CLSCompliant(true)] -[assembly: AssemblyInformationalVersion("1.8.0")] -[assembly: AssemblyVersion("1.8.0.0")] -[assembly: AssemblyFileVersion("1.8.0.0")] +[assembly: AssemblyInformationalVersion("1.8.1")] +[assembly: AssemblyVersion("1.8.1.0")] +[assembly: AssemblyFileVersion("1.8.1.0")] [assembly: AssemblyProduct("Arbitrary-Precision Number Library")] [assembly: AssemblyTitle("Arbitrary-Precision Number Library")] [assembly: AssemblyDescription("A C# library that supports arbitrary-pre" + diff --git a/Numbers40/Properties/AssemblyInfo.cs b/Numbers40/Properties/AssemblyInfo.cs index 3ca4188..208cfd2 100644 --- a/Numbers40/Properties/AssemblyInfo.cs +++ b/Numbers40/Properties/AssemblyInfo.cs @@ -1,8 +1,8 @@ using System.Reflection; [assembly: System.CLSCompliant(true)] -[assembly: AssemblyInformationalVersion("1.8.0")] -[assembly: AssemblyVersion("1.8.0.0")] -[assembly: AssemblyFileVersion("1.8.0.0")] +[assembly: AssemblyInformationalVersion("1.8.1")] +[assembly: AssemblyVersion("1.8.1.0")] +[assembly: AssemblyFileVersion("1.8.1.0")] [assembly: AssemblyProduct("Arbitrary-Precision Number Library")] [assembly: AssemblyTitle("Arbitrary-Precision Number Library")] [assembly: AssemblyDescription("A C# library that supports arbitrary-pre" + diff --git a/Test/EDecimalTest.cs b/Test/EDecimalTest.cs index 9d54ca6..9d2a0af 100644 --- a/Test/EDecimalTest.cs +++ b/Test/EDecimalTest.cs @@ -165,11 +165,11 @@ public class EDecimalTest { [Test] public void TestAddThenCompare() { EDecimal a = EDecimal.FromString( - "3432401181884624580219161996277760227145481682978308767347063168426989874100957186809774969532587926005597200790737572030389681269702414428117526594285731840"); + "3432401181884624580219161996277760227145481682978308767347063168426989874100957186809774969532587926005597200790737572030389681269702414428117526594285731840"); a = a.Add( EDecimal.FromString("18895577316172922617856")); EDecimal b = EDecimal.FromString( - "3432401181884624580219161996277760227145481682978308767347063168426989874100957186809774969532587926005597200790737572030389681269702433323694842767208349696"); + "3432401181884624580219161996277760227145481682978308767347063168426989874100957186809774969532587926005597200790737572030389681269702433323694842767208349696"); Assert.AreEqual(a.ToString(), b.ToString()); TestCommon.CompareTestEqual(a, b, String.Empty); Assert.AreEqual(a.Sign, b.Sign); @@ -292,15 +292,15 @@ public class EDecimalTest { [Test] public void TestFromDoubleBitsNaN() { - long lbits = unchecked((long)0xfff8000000000000); + long lbits = unchecked((long)0xfff8000000000000L); Assert.AreEqual(lbits, EDecimal.FromDoubleBits(lbits).ToDoubleBits()); lbits = 0x7ff8000000000000L; Assert.AreEqual(lbits, EDecimal.FromDoubleBits(lbits).ToDoubleBits()); - lbits = unchecked((long)0xfff8000000000000); + lbits = unchecked((long)0xfff8000000000000L); Assert.AreEqual(lbits, EFloat.FromDoubleBits(lbits).ToDoubleBits()); lbits = 0x7ff8000000000000L; Assert.AreEqual(lbits, EFloat.FromDoubleBits(lbits).ToDoubleBits()); - lbits = unchecked((long)0xfff8000000000000); + lbits = unchecked((long)0xfff8000000000000L); Assert.AreEqual(lbits, ERational.FromDoubleBits(lbits).ToDoubleBits()); lbits = 0x7ff8000000000000L; Assert.AreEqual(lbits, ERational.FromDoubleBits(lbits).ToDoubleBits()); @@ -311,8 +311,8 @@ public class EDecimalTest { EFloat ef; EDecimal ed; ef = EFloat.Create( - EInteger.FromString("-9664843630203122783591902764846273689479381470150824364957816856082399492757121214693125730981133439908"), - -17247); + EInteger.FromString("-9664843630203122783591902764846273689479381470150824364957816856082399492757121214693125730981133439908"), + -17247); ed = EDecimal.FromEFloat(ef); Assert.AreEqual(0, ed.CompareToBinary(ef)); } @@ -321,8 +321,8 @@ public class EDecimalTest { EFloat ef; EDecimal ed; ef = EFloat.Create( - EInteger.FromString("-2467365858090833230674801431449857270755907368718802724012643203913243742810052368602482131073985474496270026402026901711301805506483138316932981526091018161243282613098255694573218797136340778209470766121110562843973682548635610931370244160852853706133513187695008443087958097846576792398400512366911345362406722788893972946659265028631132327775167697067574535402565194880977992197706600276103283316072610566206275168152573770312869585911831390513851119697252481532540704706697299199745684224875503861044195414865414501211853220204780962526179105198234107560421422472675347263283990608089697319048891315126404866394172515587870915984406737373646406191043645162091665444977123227178202520024830788089974236992351854383678539013034083419874455158726412688896635633819017324077511735883476845008734150221821164999757875534151181805265806734244829066298005793659243034786743021850398154955226684325077441797994355484078284651814522091252889035546936605403702617900755410567544044017356945337917854344068537582739700174480391485976108360704358539233556356055416272178277957515564601573063597136628104876885194939300236889051122715898223511987845895344284500599930150533252352792434580138801671556601310092800472408049970821810559885509976187264868852561693833270555422604022272867933389426568067071959374066789450739921141187691825889495918119483261575309"), - -11254); + EInteger.FromString("-2467365858090833230674801431449857270755907368718802724012643203913243742810052368602482131073985474496270026402026901711301805506483138316932981526091018161243282613098255694573218797136340778209470766121110562843973682548635610931370244160852853706133513187695008443087958097846576792398400512366911345362406722788893972946659265028631132327775167697067574535402565194880977992197706600276103283316072610566206275168152573770312869585911831390513851119697252481532540704706697299199745684224875503861044195414865414501211853220204780962526179105198234107560421422472675347263283990608089697319048891315126404866394172515587870915984406737373646406191043645162091665444977123227178202520024830788089974236992351854383678539013034083419874455158726412688896635633819017324077511735883476845008734150221821164999757875534151181805265806734244829066298005793659243034786743021850398154955226684325077441797994355484078284651814522091252889035546936605403702617900755410567544044017356945337917854344068537582739700174480391485976108360704358539233556356055416272178277957515564601573063597136628104876885194939300236889051122715898223511987845895344284500599930150533252352792434580138801671556601310092800472408049970821810559885509976187264868852561693833270555422604022272867933389426568067071959374066789450739921141187691825889495918119483261575309"), + -11254); ed = EDecimal.FromEFloat(ef); Assert.AreEqual(0, ed.CompareToBinary(ef)); } @@ -331,8 +331,8 @@ public class EDecimalTest { EFloat ef; EDecimal ed; ef = EFloat.Create( - EInteger.FromString("-325087637545375466523593319915642000166507448768479353748943585507647929726919984092640176973845417409613528524759214900494790101204316104560025164009709666878119359566275239162086759961271534412991410161699457719070992680179292505"), - -22909); + EInteger.FromString("-325087637545375466523593319915642000166507448768479353748943585507647929726919984092640176973845417409613528524759214900494790101204316104560025164009709666878119359566275239162086759961271534412991410161699457719070992680179292505"), + -22909); ed = EDecimal.FromEFloat(ef); Assert.AreEqual(0, ed.CompareToBinary(ef)); } @@ -341,7 +341,7 @@ public class EDecimalTest { [Timeout(1000)] public void TestSlowCompareTo() { EInteger ei = EInteger.FromString( - "-108854259699738613336073386912819333959164543792902007057925129910904321192623590227704182838777516070192327852552376209933022606"); + "-108854259699738613336073386912819333959164543792902007057925129910904321192623590227704182838777516070192327852552376209933022606"); EFloat ef = EFloat.Create( ei, EInteger.FromString("-94432713210")); @@ -355,7 +355,7 @@ public class EDecimalTest { EInteger.FromString("310698658007725142033104896"), EInteger.FromString("-910015527228")); EDecimal ed = EDecimal.FromString( - "5.46812681195752988681792163205092489269012868995370381431608431437654836803981061017608940175753472E-373278497416"); + "5.46812681195752988681792163205092489269012868995370381431608431437654836803981061017608940175753472E-373278497416"); Assert.AreEqual(-1, ed.CompareToBinary(ef)); } [Test] @@ -366,18 +366,18 @@ public class EDecimalTest { string str; str = - "1766847170502052161990715830264538670879951287225036514637396697134727424"; + "1766847170502052161990715830264538670879951287225036514637396697134727424"; ef = EFloat.Create( EInteger.FromString(str), EInteger.FromString("-312166824097095580")); str = - "9.173994463968662338877236893297097756859177826848079536001717300706132083132181223420891571892014689615873E-411"; + "9.173994463968662338877236893297097756859177826848079536001717300706132083132181223420891571892014689615873E-411"; ed = EDecimal.FromString(str); Assert.AreEqual(1, ed.CompareToBinary(ef), ed.ToString()); ed = EDecimal.FromString("-0.8686542656448184"); EInteger num = EInteger.FromString( - "-140066031252330072924596216562033152419723178072587092376847513280411121126147871380984127579961289495006067586678128473926216639728812381688517268223431349786843141449122136993998169636988109708853983609451615499412285220750795244924615776386873830928453488263516664209329914433973932921432682935336466252311348743988191166143"); + "-140066031252330072924596216562033152419723178072587092376847513280411121126147871380984127579961289495006067586678128473926216639728812381688517268223431349786843141449122136993998169636988109708853983609451615499412285220750795244924615776386873830928453488263516664209329914433973932921432682935336466252311348743988191166143"); ef = EFloat.Create( num, @@ -399,7 +399,7 @@ public class EDecimalTest { ed = EDecimal.FromString( - "9.511414777277089412154948033116658722787183213120804541938141882272749696679385407387275461761800238977533242480831603777061215911374370925809077057683501541910383022943115134850573547079633633752563620027531228739865573373209036911484539031800435471797748936642897560822226476374652683917217409048036924712889788014206259609E+676"); + "9.511414777277089412154948033116658722787183213120804541938141882272749696679385407387275461761800238977533242480831603777061215911374370925809077057683501541910383022943115134850573547079633633752563620027531228739865573373209036911484539031800435471797748936642897560822226476374652683917217409048036924712889788014206259609E+676"); ef = EFloat.Create(eim, eie); Assert.AreEqual(-1, ed.CompareToBinary(ef)); } @@ -1359,19 +1359,19 @@ public class EDecimalTest { { object objectTemp = - EDecimal.FromString("0.009461540475412139260145553670698466186015902447450593622262751970123371581303298477485466592231565609"); + EDecimal.FromString("0.009461540475412139260145553670698466186015902447450593622262751970123371581303298477485466592231565609"); object objectTemp2 = - EDecimal.FromString("0.009461540475412139260145553670698466186015902447450593622262751970123371581303298477485466592231565609"); + EDecimal.FromString("0.009461540475412139260145553670698466186015902447450593622262751970123371581303298477485466592231565609"); Assert.AreEqual(objectTemp, objectTemp2); } { object objectTemp = - EDecimal.FromString("0.009461540475412139260145553670698466186015902447450593622262751970123371581303298477485466592231565609"); + EDecimal.FromString("0.009461540475412139260145553670698466186015902447450593622262751970123371581303298477485466592231565609"); object objectTemp2 = - EDecimal.FromString("0.001809476049361792727571247490438259768858020288404502743164967883090669271207537395819291033916115474"); + EDecimal.FromString("0.001809476049361792727571247490438259768858020288404502743164967883090669271207537395819291033916115474"); Assert.AreNotEqual(objectTemp, objectTemp2); } var r = new RandomGenerator(); @@ -1738,7 +1738,7 @@ public class EDecimalTest { { string stringTemp2 = - "2.29360000000000010330982488752915582352898127282969653606414794921875E-7"; + "2.29360000000000010330982488752915582352898127282969653606414794921875E-7"; Assert.AreEqual(stringTemp2, stringTemp); } } @@ -1778,7 +1778,7 @@ public class EDecimalTest { { string stringTemp2 = - "0.0000019512000000000000548530838806460252499164198525249958038330078125"; + "0.0000019512000000000000548530838806460252499164198525249958038330078125"; Assert.AreEqual(stringTemp2, stringTemp); } } @@ -1812,7 +1812,7 @@ public class EDecimalTest { stringTemp = EDecimal.FromDouble(3.1035E-5).ToString(); { string stringTemp2 = - "0.0000310349999999999967797807698399736864303122274577617645263671875"; + "0.0000310349999999999967797807698399736864303122274577617645263671875"; Assert.AreEqual(stringTemp2, stringTemp); } } @@ -1896,7 +1896,7 @@ public class EDecimalTest { { string stringTemp2 = - "0.00000323700000000000009386523676380154057596882921643555164337158203125"; + "0.00000323700000000000009386523676380154057596882921643555164337158203125"; Assert.AreEqual(stringTemp2, stringTemp); } } @@ -2041,7 +2041,7 @@ public class EDecimalTest { { string stringTemp2 = - "2.28179999999999995794237200343046456652018605382181704044342041015625E-7"; + "2.28179999999999995794237200343046456652018605382181704044342041015625E-7"; Assert.AreEqual(stringTemp2, stringTemp); } } @@ -2106,7 +2106,7 @@ public class EDecimalTest { { string stringTemp2 = - "0.00000380250000000000001586513038998038638283105683512985706329345703125"; + "0.00000380250000000000001586513038998038638283105683512985706329345703125"; Assert.AreEqual(stringTemp2, stringTemp); } } @@ -2140,7 +2140,7 @@ public class EDecimalTest { stringTemp = EDecimal.FromDouble(3.9116E-7).ToString(); { string stringTemp2 = - "3.911600000000000165617541382501176627783934236504137516021728515625E-7"; + "3.911600000000000165617541382501176627783934236504137516021728515625E-7"; Assert.AreEqual(stringTemp2, stringTemp); } } @@ -2211,7 +2211,7 @@ public class EDecimalTest { stringTemp = EDecimal.FromDouble(1.3414E-4).ToString(); { string stringTemp2 = - "0.00013414000000000001334814203612921801322954706847667694091796875"; + "0.00013414000000000001334814203612921801322954706847667694091796875"; Assert.AreEqual(stringTemp2, stringTemp); } } @@ -2221,7 +2221,7 @@ public class EDecimalTest { { string stringTemp2 = - "3.4449999999999999446924077266263264363033158588223159313201904296875E-7"; + "3.4449999999999999446924077266263264363033158588223159313201904296875E-7"; Assert.AreEqual(stringTemp2, stringTemp); } } @@ -2231,7 +2231,7 @@ public class EDecimalTest { { string stringTemp2 = - "1.3610000000000000771138253079228785935583800892345607280731201171875E-7"; + "1.3610000000000000771138253079228785935583800892345607280731201171875E-7"; Assert.AreEqual(stringTemp2, stringTemp); } } @@ -2252,7 +2252,7 @@ public class EDecimalTest { stringTemp = EDecimal.FromDouble(6.0E-6).ToString(); { string stringTemp2 = - "0.00000600000000000000015200514458246772164784488268196582794189453125"; + "0.00000600000000000000015200514458246772164784488268196582794189453125"; Assert.AreEqual(stringTemp2, stringTemp); } } @@ -2285,7 +2285,7 @@ public class EDecimalTest { stringTemp = EDecimal.FromDouble(2.331E-4).ToString(); { string stringTemp2 = - "0.00023310000000000000099260877295392901942250318825244903564453125"; + "0.00023310000000000000099260877295392901942250318825244903564453125"; Assert.AreEqual(stringTemp2, stringTemp); } } @@ -2345,7 +2345,7 @@ public class EDecimalTest { stringTemp = EDecimal.FromDouble(1.83E-5).ToString(); { string stringTemp2 = - "0.00001830000000000000097183545932910675446692039258778095245361328125"; + "0.00001830000000000000097183545932910675446692039258778095245361328125"; Assert.AreEqual(stringTemp2, stringTemp); } } @@ -3054,25 +3054,25 @@ public class EDecimalTest { [Test] [Timeout(20000)] public void TestAddSpecific() { - EDecimal ed1 = -EDecimal.FromString("-6.44157770841120149430189812635250244E+472921500817"); - EDecimal ed2 = EDecimal.FromString("162693755097376304199934012293120"); - // Should return NaN due to memory issues - ed1 = ed1.Add(ed2); - Assert.IsTrue(!ed1.IsFinite); + EDecimal ed1 = + EDecimal.FromString("-6.44157770841120149430189812635250244E+472921500817"); + EDecimal ed2 = EDecimal.FromString("162693755097376304199934012293120"); + // Should return NaN due to memory issues + ed1 = ed1.Add(ed2); + Assert.IsTrue(!ed1.IsFinite); } [Test] [Timeout(20000)] public void TestAddSpecific2() { - string estr = -"1.38142827576784791711343100763562342897471169437179108373895" + - "E-1527495144586647199842075371956087247329299647091240949"; - EDecimal ed1 = EDecimal.FromString(estr); - EDecimal ed2 = EDecimal.FromString("162693755097376304199934012293120"); - // Should return NaN due to memory issues - ed1 = ed1.Add(ed2); - Assert.IsTrue(!ed1.IsFinite); + string estr = + "1.38142827576784791711343100763562342897471169437179108373895" + + "E-1527495144586647199842075371956087247329299647091240949"; + EDecimal ed1 = EDecimal.FromString(estr); + EDecimal ed2 = EDecimal.FromString("162693755097376304199934012293120"); + // Should return NaN due to memory issues + ed1 = ed1.Add(ed2); + Assert.IsTrue(!ed1.IsFinite); } [Test] @@ -3921,7 +3921,7 @@ public class EDecimalTest { // test for correct rounding double dbl; dbl = EDecimal.FromString( - "1.972579273363468721491642554610734805464744567871093749999999999999") + "1.972579273363468721491642554610734805464744567871093749999999999999") .ToDouble(); { string stringTemp = EFloat.FromDouble(dbl).ToPlainString(); @@ -5716,7 +5716,7 @@ public class EDecimalTest { public void TestStringContextSpecific4c() { string num = - "-16120570567037778210732025954408283690946444690491951476102714548515145821906708291828685686116455423481898854735868999853690814E-7564"; + "-16120570567037778210732025954408283690946444690491951476102714548515145821906708291828685686116455423481898854735868999853690814E-7564"; TestStringContextOneEFloat(num, EContext.Binary64); } @@ -5860,29 +5860,29 @@ public class EDecimalTest { } public static void TestUnsignedLongOne(long v, string expectedStr) { - EInteger ei = EInteger.FromInt64AsUnsigned(v); - Assert.AreEqual( - expectedStr, - ToLowerCaseAscii(ei.ToRadixString(16))); - EDecimal ed = EDecimal.FromInt64AsUnsigned(v); - TestCommon.CompareTestEqual(EDecimal.FromEInteger(ei), ed); - EFloat ef = EFloat.FromInt64AsUnsigned(v); - TestCommon.CompareTestEqual(EFloat.FromEInteger(ei), ef); - ERational er = ERational.FromInt64AsUnsigned(v); - TestCommon.CompareTestEqual(ERational.FromEInteger(ei), er); + EInteger ei = EInteger.FromInt64AsUnsigned(v); + Assert.AreEqual( + expectedStr, + ToLowerCaseAscii(ei.ToRadixString(16))); + EDecimal ed = EDecimal.FromInt64AsUnsigned(v); + TestCommon.CompareTestEqual(EDecimal.FromEInteger(ei), ed); + EFloat ef = EFloat.FromInt64AsUnsigned(v); + TestCommon.CompareTestEqual(EFloat.FromEInteger(ei), ef); + ERational er = ERational.FromInt64AsUnsigned(v); + TestCommon.CompareTestEqual(ERational.FromEInteger(ei), er); } [Test] public void TestUnsignedLong() { - TestUnsignedLongOne(0x0L, "0"); - TestUnsignedLongOne(0xFL, "f"); - TestUnsignedLongOne(0xFFFFFFFFL, "ffffffff"); - TestUnsignedLongOne(-1, "ffffffffffffffff"); - TestUnsignedLongOne(-3, "fffffffffffffffd"); - TestUnsignedLongOne(Int64.MaxValue, "7fffffffffffffff"); - TestUnsignedLongOne(Int64.MaxValue - 1, "7ffffffffffffffe"); - TestUnsignedLongOne(Int64.MinValue, "8000000000000000"); - TestUnsignedLongOne(Int64.MinValue + 1, "8000000000000001"); + TestUnsignedLongOne(0x0L, "0"); + TestUnsignedLongOne(0xFL, "f"); + TestUnsignedLongOne(0xFFFFFFFFL, "ffffffff"); + TestUnsignedLongOne(-1, "ffffffffffffffff"); + TestUnsignedLongOne(-3, "fffffffffffffffd"); + TestUnsignedLongOne(Int64.MaxValue, "7fffffffffffffff"); + TestUnsignedLongOne(Int64.MaxValue - 1, "7ffffffffffffffe"); + TestUnsignedLongOne(Int64.MinValue, "8000000000000000"); + TestUnsignedLongOne(Int64.MinValue + 1, "8000000000000001"); } [Test] @@ -6282,7 +6282,7 @@ public class EDecimalTest { .WithRounding(ERounding.HalfDown); string str = - "00726010602910507435000059115940090202200019076401000797770037005004100060.0201983258000005067E-96"; + "00726010602910507435000059115940090202200019076401000797770037005004100060.0201983258000005067E-96"; TestStringContextOne(str, ec); } [Test] @@ -6294,7 +6294,7 @@ public class EDecimalTest { true).WithExponentClamp(false).WithSimplified(false); String str = - "-66534305690092119160982082298.6117943850214200578102634919915948108612006388913171795430645264401356581996334057250931572660709458186036652420658265819852148081219105264213931192572998661457444645337884797981765786873164189138929912494098111738350059458760047160519097327194211787079276441238232334641699878542658228963741574816826153104358339605788240136295139854413718595196475956646218991803499475021107664682894173676216342285575942409166581979296601101999863633968466436458631641517841792"; + "-66534305690092119160982082298.6117943850214200578102634919915948108612006388913171795430645264401356581996334057250931572660709458186036652420658265819852148081219105264213931192572998661457444645337884797981765786873164189138929912494098111738350059458760047160519097327194211787079276441238232334641699878542658228963741574816826153104358339605788240136295139854413718595196475956646218991803499475021107664682894173676216342285575942409166581979296601101999863633968466436458631641517841792"; TestStringContextOneEFloat(str, ec); } @@ -6311,7 +6311,7 @@ public class EDecimalTest { public void TestFromStringSubstring() { string tstr = - "-3.00931381333368754713014659613049757554804012787921371662913692598770508705049030832574634419795955864174175076186656951904296875000E-49"; + "-3.00931381333368754713014659613049757554804012787921371662913692598770508705049030832574634419795955864174175076186656951904296875000E-49"; try { EDecimal.FromString( "xyzxyz" + tstr, @@ -6365,22 +6365,22 @@ public class EDecimalTest { } } - // Under the General Decimal Arithmetic Specification, - // power(1.0, -integer) should act the same as power(1/1.0, integer) + // Under the General Decimal Arithmetic Specification, + // power(1.0, -integer) should act the same as power(1/1.0, integer) [Test] public void TestPowerOneExpNegativeInteger() { - string str = "precision: 16\nrounding: half_even\nminexponent:" + -"\u0020-383\nmaxexponent: 384\nextended: 1\n" + + string str = "precision: 16\nrounding: half_even\nminexponent:" + + "\u0020-383\nmaxexponent: 384\nextended: 1\n" + "custom_power_12767 power 1.0 -6290 -> 1 "; - DecTestUtil.ParseDecTests(str, false); - } + DecTestUtil.ParseDecTests(str, false); + } [Test] public void TestPowerOneExpNegativeInteger2() { - string str = "precision: 16\nrounding: half_even\nminexponent:" + -"\u0020-383\nmaxexponent: 384\nextended: 1\ncustom_power_1330 power 1.000" + -"\u0020-9287 ->" + -"\u00201"; // "1"; - DecTestUtil.ParseDecTests(str, false); + string str = "precision: 16\nrounding: half_even\nminexponent:" + + "\u0020-383\nmaxexponent: 384\nextended: 1\ncustom_power_1330 power 1.000" + + "\u0020-9287 ->" + + "\u00201"; // "1"; + DecTestUtil.ParseDecTests(str, false); } [Test] @@ -6398,90 +6398,90 @@ public class EDecimalTest { [Test] public void TestDecTestSpecificPower4() { - string str = "precision: 34\nrounding: half_even\nminexponent: " + -"-6143\nmaxexponent: 6144\nextended: 1\ncustom_power_4373 power " + -"6.69368032938021915 -52.62 -> 3.576921343298362853247641466638896E-44 " + -"Inexact Rounded"; -// "3.5769213432983628532476414666388955000992271E-44"; - DecTestUtil.ParseDecTests(str, false); + string str = "precision: 34\nrounding: half_even\nminexponent: " + + "-6143\nmaxexponent: 6144\nextended: 1\ncustom_power_4373 power " + + "6.69368032938021915 -52.62 -> 3.576921343298362853247641466638896E-44 " + + "Inexact Rounded"; + // "3.5769213432983628532476414666388955000992271E-44"; + DecTestUtil.ParseDecTests(str, false); } [Test] public void TestDecTestSpecificPower5() { - string str = "precision: 34\nrounding: half_even\nminexponent:" + -"\u0020-6143\nmaxexponent: 6144\nextended: 1\ncustom_power_9740 power 3.724" + -"\u0020-6856" + -"\u0020-> 1.437760829269881315895729920406088E-3915 Inexact Rounded"; -// "\u00201.4377608292698813158957299204060875000448219E-3915"; - DecTestUtil.ParseDecTests(str, false); + string str = "precision: 34\nrounding: half_even\nminexponent:" + + "\u0020-6143\nmaxexponent: 6144\nextended: 1\ncustom_power_9740 power 3.724" + + "\u0020-6856" + + "\u0020-> 1.437760829269881315895729920406088E-3915 Inexact Rounded"; + // "\u00201.4377608292698813158957299204060875000448219E-3915"; + DecTestUtil.ParseDecTests(str, false); } [Test] public void TestDecTestSpecificPower6() { - string str = "precision: 34\nrounding: half_even\nminexponent:" + -"\u0020-6143\nmaxexponent: 6144\nextended: 1\ncustom_power_17409 power" + -"\u00200.009326" + -"\u0020-75.59 -> 2.956132346267103882996614250892197E\u002b153 Inexact Rounded"; -// "\u00202.9561323462671038829966142508921974999579417E+153"; - DecTestUtil.ParseDecTests(str, false); + string str = "precision: 34\nrounding: half_even\nminexponent:" + + "\u0020-6143\nmaxexponent: 6144\nextended: 1\ncustom_power_17409 power" + + "\u00200.009326" + + "\u0020-75.59 -> 2.956132346267103882996614250892197E\u002b153 Inexact Rounded"; + // "\u00202.9561323462671038829966142508921974999579417E+153"; + DecTestUtil.ParseDecTests(str, false); } [Test] public void TestDecTestSpecificPower7() { - string str = "precision: 34\nrounding: half_even\nminexponent:" + -"\u0020-6143\nmaxexponent: 6144\nextended: 1\ncustom_power_19421 power" + -"\u00201.6026491E-8" + -"\u0020-91.7 -> 6.551106896440510811119799436358778E\u002b714 Inexact Rounded"; -// "\u00206.5511068964405108111197994363587784994316246E+714"; - DecTestUtil.ParseDecTests(str, false); + string str = "precision: 34\nrounding: half_even\nminexponent:" + + "\u0020-6143\nmaxexponent: 6144\nextended: 1\ncustom_power_19421 power" + + "\u00201.6026491E-8" + + "\u0020-91.7 -> 6.551106896440510811119799436358778E\u002b714 Inexact Rounded"; + // "\u00206.5511068964405108111197994363587784994316246E+714"; + DecTestUtil.ParseDecTests(str, false); } [Test] public void TestDecTestSpecificPower8() { - string str = "precision: 16\nrounding: half_even\nminexponent:" + -"\u0020-383\nmaxexponent: 384\nextended: 1\ncustom_power_14214 power -0.05304" + -"\u0020-7.000 -> -846789359.6071463 Inexact Rounded"; - DecTestUtil.ParseDecTests(str, false); + string str = "precision: 16\nrounding: half_even\nminexponent:" + + "\u0020-383\nmaxexponent: 384\nextended: 1\ncustom_power_14214 power -0.05304" + + "\u0020-7.000 -> -846789359.6071463 Inexact Rounded"; + DecTestUtil.ParseDecTests(str, false); } [Test] public void TestDecTestSpecificPower9() { - string str = "precision: 34\nrounding: half_even\nminexponent:" + -"\u0020-6143\nmaxexponent: 6144\nextended: 1\ncustom_power_18478 power" + -"\u00200.007432" + -"\u0020-66.89 -> 2.521968518855321930003285016375665E\u002b142 Inexact Rounded"; -// "\u00202.5219685188553219300032850163756645000465660E+142"; - DecTestUtil.ParseDecTests(str, false); + string str = "precision: 34\nrounding: half_even\nminexponent:" + + "\u0020-6143\nmaxexponent: 6144\nextended: 1\ncustom_power_18478 power" + + "\u00200.007432" + + "\u0020-66.89 -> 2.521968518855321930003285016375665E\u002b142 Inexact Rounded"; + // "\u00202.5219685188553219300032850163756645000465660E+142"; + DecTestUtil.ParseDecTests(str, false); } [Test] public void TestDecTestSpecificPower1() { - string str = "precision: 34\nrounding: half_even\nminexponent: -6143\n" + - "maxexponent: 6144\nextended:1\n" + - "custom_power_16 power 0.07585 -756.0 -> " + - "5.669929347251241273640310019664757E+846 Inexact Rounded"; - DecTestUtil.ParseDecTests( - str, - false); + string str = "precision: 34\nrounding: half_even\nminexponent: -6143\n" + + "maxexponent: 6144\nextended:1\n" + + "custom_power_16 power 0.07585 -756.0 -> " + + "5.669929347251241273640310019664757E+846 Inexact Rounded"; + DecTestUtil.ParseDecTests( + str, + false); } [Test] public void TestDecTestSpecificPower2() { - string str = "precision: 34\nrounding: half_even\nminexponent: -6143\n" + - "maxexponent: 6144\nextended:1\n" + - "custom_power_16 power 0.0060351448 -472.9 -> " + - "3.256786372719241448264997647923555E+1049 Inexact Rounded"; - DecTestUtil.ParseDecTests( - str, - false); + string str = "precision: 34\nrounding: half_even\nminexponent: -6143\n" + + "maxexponent: 6144\nextended:1\n" + + "custom_power_16 power 0.0060351448 -472.9 -> " + + "3.256786372719241448264997647923555E+1049 Inexact Rounded"; + DecTestUtil.ParseDecTests( + str, + false); } [Test] public void TestDecTestSpecificPower3() { - string str = "precision: 34\nrounding: half_even\nminexponent: -6143\n" + - "maxexponent: 6144\nextended:1\n" + - "custom_power_1334 power 0.04749 -448.8 -> " + - "8.728634162796843910279804297263345E+593 Inexact Rounded"; - DecTestUtil.ParseDecTests( - str, - false); + string str = "precision: 34\nrounding: half_even\nminexponent: -6143\n" + + "maxexponent: 6144\nextended:1\n" + + "custom_power_1334 power 0.04749 -448.8 -> " + + "8.728634162796843910279804297263345E+593 Inexact Rounded"; + DecTestUtil.ParseDecTests( + str, + false); } [Test] @@ -6532,7 +6532,7 @@ public class EDecimalTest { true).WithExponentClamp(true).WithSimplified(false); string str = - "0073000021960980007305056484911080609040458307738480635500600457003065700100902090896615030732652553075037501950247305214001000609697011805466300376799178890090568606761710483020290709180410260358805508079072601000651506000108202180008505073022007850910039820241008201400236050050246900250895790030707320060332426231940803760330870307891088002560602070261700009603405009775900250580042858910209705051402664037402890735007100990890000080400608930007400063761001060038422005000901008707958734420510029017800102078015560159466901008804187630045304308036045704003720440800815040565098720007028200106057003008686040653375800708409606600950560830030801760629754000760076605050983054030300803305080990620430700840009286601907275803099010881000640070927000080000008405306277002008029320337060582690200276900884274000901881004000310130000010529021820708007358724730000264010468066140278717080644405250055023049005410260170061028282960000387000838458809907775526543276066028052520064503000100807184090046410708762022080505049057381004290108034510779400054092008480560904006710454005310519093930221902122039610110010310904999053064480005347036006292155510100964159041000000080600200100953050100060302304400634050055060861170040001026314715506000820010098082607848000300070322081050000867074060748210041090041240035812005308214300200822920208400270023090003110479608027914239601710012061077000000001366560070009908108210007200750510209013151790093000730800276080250400008507803982439000000100669040403095399000960069280699214017925506071788615943730001561163245370150912016780305000103085005002106910768477605450240090047901050014022241930983590520881960050016606569010002040010370729830045000941024068389350459300480300460129770020070002010620036091110067768612651641004505298037850000830052791040670031808464000400917134087560809900804039066079020994020480506102558203708801200020055570506007057370403232340060613900619082084008555809560002551508005090489460838796507547672109005864200042100300800202808375953761040902004824600723084003003588014870008004933604890506600283627630387525107610907076802062000707616040007004667672660696000803953009260500830623049700845959005030500345031202000705360600000390110950008663000307062070324006059000068150026170125510711631670061503700990508040003960989089053312086107836920027007406700037704711600129067105252600004920298536005058003378580770002980990070504061768302300582325530610900070088099090323600407001087000440930030462709046304080073000593087600000344409005232117218901836766839909000807090823449060248032004031900400110470891000900601010431160000070805200609304320030476297778010900166400814109652150659007000004880205940084400030100534010300901904843027618403007084007410069934011066490027980605006620507000062039401035282097008512010185715616200003399000005045063608090067334002280090404390702501970603454069394005030700607001900941079758000519044404070855813207865778701005089030470063099108055888010000003500002327800542400707001714596712000400990450450094099170006070110660063300076733101806000077642101002303300105052300040581500702107300406209568326733460000050017760050800006777088068746920122152940222758028000744600119619246910290007803096261105023025068095480520103800879006903026138000075065382650022776414190069820188028458006098597000080229201880402170000023708000300233407460107004002100620601037785440008078000275604004145076507670153209445808502222360303327008009610000262892306003242430010300100300507208955280567155839100609759005082306090914146902008430007000356015185204375040562052010010106300370778308000027123420720080032072501006300902004395951040000035010055000070046080700080705006107706038049944005988070566700080000060273468025208869030759887691081340130051960076000810308727414108000040900005603783030824102080636044620119003403060406395605000000809000049693800000740740548264030900006320682153099988100417093340603621381680099828609008563245960739002010070080007093003000804025952503731474790226099261408010000790030302007718888342790470174084922301628701101613035300282601960820160194870077649252500091663420030054007077905000998009400886261390733103000189409201720888050111740989704007008606106600080833500509085085930806453406370977000439088350070539980687301901401050603080033918420570708904206031303051194000941044249882850350287700217022108640280058008034061255000708900005700182580214020076828009160506803309889379942603028064058021500016134500890569952490601000374000006654005340022209600080005977940420305900046963005063030214062337813016809210709203009208235500500922080001007072405558870306333550007038602140692020099072607760612384761090084000690025083900500374028101052519672720000485054141000704300306977025038900163623020400088010119763150804236200401850001001409500077000303050003009603400650005700902000072307202045707346000000167205713464110440039353600000399904610342901843008000005594505070080205000700000053290017653000628060060690030314284647630000227060008200230620510520606048052224017172525569283900900608092340909200258090778365000018156400220054455624700957208070003317950118450666253954414360904060640038749620706821283188030017057660780030100200874602220708065100205806002801008020070900349008951201003309048007037020034030719039090741410281099409002350082853006190004501527010804016220045556053282803803963075710866040620903150683367989410091680380309001070040036004901694203009806750070136107031500028738630130672000108030203200903203164022990715040206153000080002807000089400800510090316601000897800270023400240061092603021855008103721301372064900094700101400099060000370001204460046540253039940435053492530192158900041900801069002870000208420076700840560446600901800000007005210091070230011680030100844939703300020814109588024500654010010591923310010000258070220317280470889600010630004302304116034597040040400079961220303019772608870000007900080070807270804860260006000180013914550718684524093070000900960002370080001006099036005109603605005000000720290690207143018030912104700417603710790049567030554608500000490900420008109490930680201788168084422807403098800879740010800510180314329503000090907036709400073080057602060260501004308490265400394E-6200"; + "0073000021960980007305056484911080609040458307738480635500600457003065700100902090896615030732652553075037501950247305214001000609697011805466300376799178890090568606761710483020290709180410260358805508079072601000651506000108202180008505073022007850910039820241008201400236050050246900250895790030707320060332426231940803760330870307891088002560602070261700009603405009775900250580042858910209705051402664037402890735007100990890000080400608930007400063761001060038422005000901008707958734420510029017800102078015560159466901008804187630045304308036045704003720440800815040565098720007028200106057003008686040653375800708409606600950560830030801760629754000760076605050983054030300803305080990620430700840009286601907275803099010881000640070927000080000008405306277002008029320337060582690200276900884274000901881004000310130000010529021820708007358724730000264010468066140278717080644405250055023049005410260170061028282960000387000838458809907775526543276066028052520064503000100807184090046410708762022080505049057381004290108034510779400054092008480560904006710454005310519093930221902122039610110010310904999053064480005347036006292155510100964159041000000080600200100953050100060302304400634050055060861170040001026314715506000820010098082607848000300070322081050000867074060748210041090041240035812005308214300200822920208400270023090003110479608027914239601710012061077000000001366560070009908108210007200750510209013151790093000730800276080250400008507803982439000000100669040403095399000960069280699214017925506071788615943730001561163245370150912016780305000103085005002106910768477605450240090047901050014022241930983590520881960050016606569010002040010370729830045000941024068389350459300480300460129770020070002010620036091110067768612651641004505298037850000830052791040670031808464000400917134087560809900804039066079020994020480506102558203708801200020055570506007057370403232340060613900619082084008555809560002551508005090489460838796507547672109005864200042100300800202808375953761040902004824600723084003003588014870008004933604890506600283627630387525107610907076802062000707616040007004667672660696000803953009260500830623049700845959005030500345031202000705360600000390110950008663000307062070324006059000068150026170125510711631670061503700990508040003960989089053312086107836920027007406700037704711600129067105252600004920298536005058003378580770002980990070504061768302300582325530610900070088099090323600407001087000440930030462709046304080073000593087600000344409005232117218901836766839909000807090823449060248032004031900400110470891000900601010431160000070805200609304320030476297778010900166400814109652150659007000004880205940084400030100534010300901904843027618403007084007410069934011066490027980605006620507000062039401035282097008512010185715616200003399000005045063608090067334002280090404390702501970603454069394005030700607001900941079758000519044404070855813207865778701005089030470063099108055888010000003500002327800542400707001714596712000400990450450094099170006070110660063300076733101806000077642101002303300105052300040581500702107300406209568326733460000050017760050800006777088068746920122152940222758028000744600119619246910290007803096261105023025068095480520103800879006903026138000075065382650022776414190069820188028458006098597000080229201880402170000023708000300233407460107004002100620601037785440008078000275604004145076507670153209445808502222360303327008009610000262892306003242430010300100300507208955280567155839100609759005082306090914146902008430007000356015185204375040562052010010106300370778308000027123420720080032072501006300902004395951040000035010055000070046080700080705006107706038049944005988070566700080000060273468025208869030759887691081340130051960076000810308727414108000040900005603783030824102080636044620119003403060406395605000000809000049693800000740740548264030900006320682153099988100417093340603621381680099828609008563245960739002010070080007093003000804025952503731474790226099261408010000790030302007718888342790470174084922301628701101613035300282601960820160194870077649252500091663420030054007077905000998009400886261390733103000189409201720888050111740989704007008606106600080833500509085085930806453406370977000439088350070539980687301901401050603080033918420570708904206031303051194000941044249882850350287700217022108640280058008034061255000708900005700182580214020076828009160506803309889379942603028064058021500016134500890569952490601000374000006654005340022209600080005977940420305900046963005063030214062337813016809210709203009208235500500922080001007072405558870306333550007038602140692020099072607760612384761090084000690025083900500374028101052519672720000485054141000704300306977025038900163623020400088010119763150804236200401850001001409500077000303050003009603400650005700902000072307202045707346000000167205713464110440039353600000399904610342901843008000005594505070080205000700000053290017653000628060060690030314284647630000227060008200230620510520606048052224017172525569283900900608092340909200258090778365000018156400220054455624700957208070003317950118450666253954414360904060640038749620706821283188030017057660780030100200874602220708065100205806002801008020070900349008951201003309048007037020034030719039090741410281099409002350082853006190004501527010804016220045556053282803803963075710866040620903150683367989410091680380309001070040036004901694203009806750070136107031500028738630130672000108030203200903203164022990715040206153000080002807000089400800510090316601000897800270023400240061092603021855008103721301372064900094700101400099060000370001204460046540253039940435053492530192158900041900801069002870000208420076700840560446600901800000007005210091070230011680030100844939703300020814109588024500654010010591923310010000258070220317280470889600010630004302304116034597040040400079961220303019772608870000007900080070807270804860260006000180013914550718684524093070000900960002370080001006099036005109603605005000000720290690207143018030912104700417603710790049567030554608500000490900420008109490930680201788168084422807403098800879740010800510180314329503000090907036709400073080057602060260501004308490265400394E-6200"; TestStringContextOneEFloat(str, ec); } } @@ -6542,62 +6542,62 @@ public class EDecimalTest { string decstr = "0E100441809235791722330759976"; Assert.AreEqual(0L, EDecimal.FromString(decstr).ToDoubleBits()); Assert.AreEqual(0L, EFloat.FromString(decstr).ToDoubleBits()); - { + { object objectTemp = 0L; object objectTemp2 = EDecimal.FromString(decstr, - EContext.Decimal32).ToDoubleBits(); + EContext.Decimal32).ToDoubleBits(); Assert.AreEqual(objectTemp, objectTemp2); } { object objectTemp = 0L; object objectTemp2 = EFloat.FromString(decstr, - EContext.Binary64).ToDoubleBits(); + EContext.Binary64).ToDoubleBits(); Assert.AreEqual(objectTemp, objectTemp2); } decstr = "0E-100441809235791722330759976"; Assert.AreEqual(0L, EDecimal.FromString(decstr).ToDoubleBits()); Assert.AreEqual(0L, EFloat.FromString(decstr).ToDoubleBits()); - { + { object objectTemp = 0L; object objectTemp2 = EDecimal.FromString(decstr, - EContext.Decimal32).ToDoubleBits(); + EContext.Decimal32).ToDoubleBits(); Assert.AreEqual(objectTemp, objectTemp2); } { object objectTemp = 0L; object objectTemp2 = EFloat.FromString(decstr, - EContext.Binary64).ToDoubleBits(); + EContext.Binary64).ToDoubleBits(); Assert.AreEqual(objectTemp, objectTemp2); } decstr = "-0E100441809235791722330759976"; long negzero = 1L << 63; Assert.AreEqual(negzero, EDecimal.FromString(decstr).ToDoubleBits()); Assert.AreEqual(negzero, EFloat.FromString(decstr).ToDoubleBits()); - { + { object objectTemp = negzero; object objectTemp2 = EDecimal.FromString(decstr, - EContext.Decimal32).ToDoubleBits(); + EContext.Decimal32).ToDoubleBits(); Assert.AreEqual(objectTemp, objectTemp2); } { object objectTemp = negzero; object objectTemp2 = EFloat.FromString(decstr, - EContext.Binary64).ToDoubleBits(); + EContext.Binary64).ToDoubleBits(); Assert.AreEqual(objectTemp, objectTemp2); } decstr = "-0E-100441809235791722330759976"; Assert.AreEqual(negzero, EDecimal.FromString(decstr).ToDoubleBits()); Assert.AreEqual(negzero, EFloat.FromString(decstr).ToDoubleBits()); - { + { object objectTemp = negzero; object objectTemp2 = EDecimal.FromString(decstr, - EContext.Decimal32).ToDoubleBits(); + EContext.Decimal32).ToDoubleBits(); Assert.AreEqual(objectTemp, objectTemp2); } { object objectTemp = negzero; object objectTemp2 = EFloat.FromString(decstr, - EContext.Binary64).ToDoubleBits(); + EContext.Binary64).ToDoubleBits(); Assert.AreEqual(objectTemp, objectTemp2); } } @@ -6806,14 +6806,14 @@ public class EDecimalTest { EDecimal ed = EDecimal.FromString("xyzxyz" + sbs, 6, sbs.Length); if (rand.UniformInt(100) < 10) { EDecimal ed2 = EDecimal.FromString(("xyzxyz" + sbs).ToCharArray(), - 6, - sbs.Length); + 6, + sbs.Length); Assert.AreEqual(ed, ed2); } if (rand.UniformInt(100) < 10) { EDecimal ed2 = EDecimal.FromString(StringToBytes("xyzxyz" + sbs), - 6, - sbs.Length); + 6, + sbs.Length); Assert.AreEqual(ed, ed2); } for (var j = 0; j < econtexts.Length; ++j) { diff --git a/Test/EFloatTest.cs b/Test/EFloatTest.cs index d3078a9..deb5933 100644 --- a/Test/EFloatTest.cs +++ b/Test/EFloatTest.cs @@ -318,19 +318,19 @@ public class EFloatTest { { object objectTemp = - EFloat.FromString("0.009461540475412139260145553670698466186015902447450593622262751970123371581303298477485466592231565609"); + EFloat.FromString("0.009461540475412139260145553670698466186015902447450593622262751970123371581303298477485466592231565609"); object objectTemp2 = - EFloat.FromString("0.009461540475412139260145553670698466186015902447450593622262751970123371581303298477485466592231565609"); + EFloat.FromString("0.009461540475412139260145553670698466186015902447450593622262751970123371581303298477485466592231565609"); Assert.AreEqual(objectTemp, objectTemp2); } { object objectTemp = - EFloat.FromString("0.009461540475412139260145553670698466186015902447450593622262751970123371581303298477485466592231565609"); + EFloat.FromString("0.009461540475412139260145553670698466186015902447450593622262751970123371581303298477485466592231565609"); object objectTemp2 = - EFloat.FromString("0.001809476049361792727571247490438259768858020288404502743164967883090669271207537395819291033916115474"); + EFloat.FromString("0.001809476049361792727571247490438259768858020288404502743164967883090669271207537395819291033916115474"); Assert.AreNotEqual(objectTemp, objectTemp2); } var r = new RandomGenerator(); @@ -872,23 +872,23 @@ public class EFloatTest { Assert.IsFalse(EFloat.SignalingNaN.IsZero); } - [Test] - public void TestCloseToPowerOfTwo() { - string[] variations = { - String.Empty, ".0", ".00", ".000", - ".4", ".40", ".6", ".60", ".5", ".50", ".500", - }; - for (var i = 31; i < 129; ++i) { - EInteger ei = EInteger.FromInt32(1).ShiftLeft(i); - foreach (string vari in variations) { - TestStringToDoubleSingleOne(ei.ToString() + vari); - TestStringToDoubleSingleOne(ei.Add(1).ToString() + vari); - TestStringToDoubleSingleOne(ei.Subtract(1).ToString() + vari); - TestStringToDoubleSingleOne(ei.Add(2).ToString() + vari); - TestStringToDoubleSingleOne(ei.Subtract(2).ToString() + vari); - } - } - } + [Test] + public void TestCloseToPowerOfTwo() { + string[] variations = { + String.Empty, ".0", ".00", ".000", + ".4", ".40", ".6", ".60", ".5", ".50", ".500", + }; + for (var i = 31; i < 129; ++i) { + EInteger ei = EInteger.FromInt32(1).ShiftLeft(i); + foreach (string vari in variations) { + TestStringToDoubleSingleOne(ei.ToString() + vari); + TestStringToDoubleSingleOne(ei.Add(1).ToString() + vari); + TestStringToDoubleSingleOne(ei.Subtract(1).ToString() + vari); + TestStringToDoubleSingleOne(ei.Add(2).ToString() + vari); + TestStringToDoubleSingleOne(ei.Subtract(2).ToString() + vari); + } + } + } public static void TestParseNumberFxxLine(string line) { // Parse test case format used in: @@ -914,41 +914,42 @@ public class EFloatTest { public static void TestParseNumberFxx( string str, - short _f16, + short f16, int f32, long f64, string line) { - // TODO: Support f16 test - // TODO: Add From/ToHalfBits in EDecimal/EFloat/ERational - EFloat efsng = EFloat.FromSingleBits(f32); - EFloat efdbl = EFloat.FromDoubleBits(f64); - // Begin test - if (efsng.IsFinite) { - TestStringToSingleOne(str); - } - if (efdbl.IsFinite) { - TestStringToDoubleOne(str); - } - EFloat ef; - ef = EFloat.FromString(str, EContext.Binary64); - Assert.AreEqual(f64, ef.ToDoubleBits(), line); - ef = EFloat.FromString(str, EContext.Binary32); - Assert.AreEqual(f32, ef.ToSingleBits(), line); - ef = EFloat.FromString( + Assert.AreEqual(f16, f16); + // TODO: Support f16 test + // TODO: Add From/ToHalfBits in EDecimal/EFloat/ERational + EFloat efsng = EFloat.FromSingleBits(f32); + EFloat efdbl = EFloat.FromDoubleBits(f64); + // Begin test + if (efsng.IsFinite) { + TestStringToSingleOne(str); + } + if (efdbl.IsFinite) { + TestStringToDoubleOne(str); + } + EFloat ef; + ef = EFloat.FromString(str, EContext.Binary64); + Assert.AreEqual(f64, ef.ToDoubleBits(), line); + ef = EFloat.FromString(str, EContext.Binary32); + Assert.AreEqual(f32, ef.ToSingleBits(), line); + ef = EFloat.FromString( "xxx" + str + "xxx", 3, str.Length, EContext.Binary64); - Assert.AreEqual(f64, ef.ToDoubleBits(), line); - ef = EFloat.FromString( + Assert.AreEqual(f64, ef.ToDoubleBits(), line); + ef = EFloat.FromString( "xxx" + str + "xxx", 3, str.Length, EContext.Binary32); - Assert.AreEqual(f32, ef.ToSingleBits(), line); - EDecimal ed = EDecimal.FromString(str); - Assert.AreEqual(ed.ToSingleBits(), f32, str); - Assert.AreEqual(ed.ToDoubleBits(), f64, str); + Assert.AreEqual(f32, ef.ToSingleBits(), line); + EDecimal ed = EDecimal.FromString(str); + Assert.AreEqual(ed.ToSingleBits(), f32, str); + Assert.AreEqual(ed.ToDoubleBits(), f64, str); } [Test] @@ -1016,7 +1017,7 @@ public class EFloatTest { [Test] public void TestLogExpSpecificA() { EFloat efa = EFloat.Create(5094638944929121L, - -43).ExpM1(EContext.Binary64); + -43).ExpM1(EContext.Binary64); EInteger mant = efa.Mantissa; Assert.IsTrue(mant.Abs().GetUnsignedBitLengthAsInt64() <= 53); EFloat efb = EFloat.Create(6823497764200007L, 783); @@ -1035,7 +1036,7 @@ public class EFloatTest { [Test] public void TestLogExpSpecificC() { EFloat efa = EFloat.Create(-1184982539430741L, - -52).Exp(EContext.Binary64); + -52).Exp(EContext.Binary64); EInteger mant = efa.Mantissa; Assert.IsTrue(mant.Abs().GetUnsignedBitLengthAsInt64() <= 53); EFloat efb = EFloat.Create(6923387652188847L, -53); @@ -1045,7 +1046,7 @@ public class EFloatTest { [Test] public void TestLogExpSpecificD() { EFloat efa = EFloat.Create(6832986215039611L, - -38).Log1P(EContext.Binary64); + -38).Log1P(EContext.Binary64); EFloat efb = EFloat.Create(1424402087294909L, -47); string str = OutputEF(efb) + "\n" + OutputEF(efa); TestCommon.CompareTestEqual(efb, efa, str); @@ -1053,7 +1054,7 @@ public class EFloatTest { [Test] public void TestLogExpSpecificE() { EFloat efa = EFloat.Create(5615046595603761L, - -44).ExpM1(EContext.Binary64); + -44).ExpM1(EContext.Binary64); EInteger mant = efa.Mantissa; Assert.IsTrue(mant.Abs().GetUnsignedBitLengthAsInt64() <= 53); EFloat efb = EFloat.Create(6269016557695007L, 408); @@ -2125,10 +2126,10 @@ public class EFloatTest { false).WithExponentClamp(true).WithSimplified(false); EInteger emant = - EInteger.FromString("88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888"); + EInteger.FromString("88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888"); EInteger eexp = - EInteger.FromString("1000000000000000000000000000000000000000000000000000000000000"); + EInteger.FromString("1000000000000000000000000000000000000000000000000000000000000"); EFloat efmant = EFloat.FromEInteger(emant); EFloat efexp = EFloat.FromEInteger(eexp); EFloat ef2 = efmant.Multiply(efexp, ec); @@ -2143,10 +2144,10 @@ public class EFloatTest { public void TestStringToDoubleSpecificA() { string str = - "395327047447757233151852025916007341543830859020311182348280049405196796002596109672166636419495856284607016106216608940280159980410562166599659829549836399698289289291865158130408917411887384321629920907652092446340673107744633313627817849916899822288644199811238047243389339131191051062809216261025215824523.4450649076678708780046658731481724174843552673744114894507741447375332545091864773666544122664744761333144781246291659228465651037706198817528715653479238826021855332253112859123685832653222952164708641577926580176434675271038652656763152189489079211898438385589908245057380361924564889535903026779733005698423207728797753101352096950270825633677221801202735885609696599439158086869381984718373482202897732285374878471795568389970731523802567947950548336665365358918558902407299370109971613731348136804887326596306602541763433746075226973971630905830686044475031568633180101625817896363428603835057150659940109566037118543874354367476000190935017225290762348459773388606367426256772899921636"; + "395327047447757233151852025916007341543830859020311182348280049405196796002596109672166636419495856284607016106216608940280159980410562166599659829549836399698289289291865158130408917411887384321629920907652092446340673107744633313627817849916899822288644199811238047243389339131191051062809216261025215824523.4450649076678708780046658731481724174843552673744114894507741447375332545091864773666544122664744761333144781246291659228465651037706198817528715653479238826021855332253112859123685832653222952164708641577926580176434675271038652656763152189489079211898438385589908245057380361924564889535903026779733005698423207728797753101352096950270825633677221801202735885609696599439158086869381984718373482202897732285374878471795568389970731523802567947950548336665365358918558902407299370109971613731348136804887326596306602541763433746075226973971630905830686044475031568633180101625817896363428603835057150659940109566037118543874354367476000190935017225290762348459773388606367426256772899921636"; string strb = - "179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792"; + "179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792"; EDecimal eda = EDecimal.FromString(str); EDecimal edb = EDecimal.FromString(strb); TestCommon.CompareTestLess(edb, eda); @@ -2958,17 +2959,19 @@ public class EFloatTest { TestToFloatRoundingOne(objectTemp, true); } { + string rrs = "-1000000000000000000000000000" + + "0000000000000000000000000"; EFloat objectTemp = EFloat.Create( - EInteger.FromRadixString("-10000000000000000000000000000000000000000000000000000", 2), - EInteger.FromInt32(-1074)); + EInteger.FromRadixString(rrs, 2), + EInteger.FromInt32(-1074)); TestToFloatRoundingOne(objectTemp, true); objectTemp = EFloat.Create( EInteger.FromRadixString("1010011", 2), EInteger.FromInt32(-1034)); TestToFloatRoundingOne(objectTemp, true); objectTemp = EFloat.Create( - EInteger.FromRadixString("100110100000000011000010111000111111101", 2), - EInteger.FromInt32(-1073)); + EInteger.FromRadixString("100110100000000011000010111000111111101", 2), + EInteger.FromInt32(-1073)); TestToFloatRoundingOne(objectTemp, true); } } diff --git a/docs/PeterO.Numbers.EInteger.md b/docs/PeterO.Numbers.EInteger.md index 8833db4..2b96f6a 100644 --- a/docs/PeterO.Numbers.EInteger.md +++ b/docs/PeterO.Numbers.EInteger.md @@ -96,7 +96,7 @@ Applications should instead use dedicated security libraries to handle big numbe * [GetUnsignedBitLength()](#GetUnsignedBitLength) - Deprecated: This method may overflow. Use GetUnsignedBitLengthAsEInteger instead. * [GetUnsignedBitLengthAsEInteger()](#GetUnsignedBitLengthAsEInteger) - Finds the minimum number of bits needed to represent this number's absolute value, and returns that number of bits as an arbitrary-precision integer. * [GetUnsignedBitLengthAsInt64()](#GetUnsignedBitLengthAsInt64) - Finds the minimum number of bits needed to represent this number's absolute value, and returns that number of bits as a 64-bit signed integer. -* [Imp(PeterO.Numbers.EInteger)](#Imp_PeterO_Numbers_EInteger) - Deprecated: Does the incorrect implication operation. Use Imply instead. +* [Imp(PeterO.Numbers.EInteger)](#Imp_PeterO_Numbers_EInteger) - Does an OR NOT operation between this arbitrary-precision integer and another one. * [implicit operator PeterO.Numbers.EInteger(byte)](#implicit_operator_PeterO_Numbers_EInteger_byte) - Converts a byte (from 0 to 255) to an arbitrary-precision integer. * [implicit operator PeterO.Numbers.EInteger(int)](#implicit_operator_PeterO_Numbers_EInteger_int) - Converts a 32-bit signed integer to an arbitrary-precision integer. * [implicit operator PeterO.Numbers.EInteger(long)](#implicit_operator_PeterO_Numbers_EInteger_long) - Converts a 64-bit signed integer to an arbitrary-precision integer. @@ -105,7 +105,6 @@ Applications should instead use dedicated security libraries to handle big numbe * [implicit operator PeterO.Numbers.EInteger(uint)](#implicit_operator_PeterO_Numbers_EInteger_uint) - Converts a 32-bit signed integer to an arbitrary-precision integer. * [implicit operator PeterO.Numbers.EInteger(ulong)](#implicit_operator_PeterO_Numbers_EInteger_ulong) - Converts a 64-bit unsigned integer to an arbitrary-precision integer. * [implicit operator PeterO.Numbers.EInteger(ushort)](#implicit_operator_PeterO_Numbers_EInteger_ushort) - Converts a 16-bit unsigned integer to an arbitrary-precision integer. -* [Imply(PeterO.Numbers.EInteger)](#Imply_PeterO_Numbers_EInteger) - Not documented yet. * [Increment()](#Increment) - Returns one added to this arbitrary-precision integer. * [IsEven](#IsEven) - Gets a value indicating whether this value is even. * [IsPowerOfTwo](#IsPowerOfTwo) - Gets a value indicating whether this object's value is a power of two, and greater than 0. @@ -1694,8 +1693,6 @@ The number of bits in this object's absolute value. Returns 0 if this object's v public PeterO.Numbers.EInteger Imp( PeterO.Numbers.EInteger second); -Deprecated. Does the incorrect implication operation. Use Imply instead. - Does an OR NOT operation between this arbitrary-precision integer and another one. Each arbitrary-precision integer is treated as a two's-complement form (see ["Forms of numbers"](PeterO.Numbers.EDecimal.md)"Forms of numbers" ) for the purposes of this operator. @@ -1708,30 +1705,6 @@ Each arbitrary-precision integer is treated as a two's-complement form (see [&#x An arbitrary-precision integer in which each bit is set if the corresponding bit of this integer is set, the other integer's corresponding bit is not set, or both. For example, in binary, 10110 OR NOT 11010 = 00100 (or in decimal, 22 OR NOT 26 = 23). This method uses the two's complement form of negative integers (see ["Forms of numbers"](PeterO.Numbers.EDecimal.md)"Forms of numbers" ). For example, in binary, ...11101110 OR NOT 01011 = ...11111110 (or in decimal, -18 OR 11 = -2). -Exceptions: - - * System.ArgumentNullException: -The parameter second - is null. - - -### Imply - - public PeterO.Numbers.EInteger Imply( - PeterO.Numbers.EInteger second); - -Not documented yet. - -Not documented yet. - -Parameters: - - * second: Not documented yet. - -Return Value: - -The return value is not documented yet. - Exceptions: * System.ArgumentNullException: