@@ -24,7 +24,7 @@ namespace BlazesRusCode
2424 // / Alternative Non-Integer number representation with focus on accuracy and partially speed within certain range
2525 // / Represents +- 2147483647.999999999 with 100% consistency of accuracy for most operations as long as don't get too small
2626 // / plus support for some fractal operations etc
27- // / (Support for Num/denominator representation, (Value*PI), Mixed Fractions, and other optional reps)
27+ // / (Support for Num/denominator representation, (Value*PI), Mixed Fractions(if AltDec_EnableMixedFractional) , and other optional reps)
2828 // / If AltDec_EnableENum is true and AltDec_EnableImaginaryNum is false(used when ExtraRep is negative if only one of them is enabled),
2929 // / then will support +- 2147483647.999999999E and +- 2147483647.999999999E/(Denom in range 1-2147483646)
3030 // / If AltDec_EnableImaginaryNum is true and AltDec_EnableENum is false(used when ExtraRep is negative if only one of them is enabled),
@@ -101,6 +101,7 @@ namespace BlazesRusCode
101101 ExtraRep = Divisor;
102102 }
103103
104+ #if defined(AltDec_EnableMixedFractional)
104105 void SetMixedFractionalVal (int WholeNum, int Numerator, int Denom)
105106 {
106107 IntValue = Value.IntValue ;
@@ -114,6 +115,7 @@ namespace BlazesRusCode
114115 DecimalHalf = Numerator;
115116 ExtraRep = Divisor;
116117 }
118+ #endif
117119
118120protected:
119121 static AltDec PINumValue ()
@@ -256,6 +258,7 @@ namespace BlazesRusCode
256258 }
257259#endif
258260 }
261+ #if AltDec_EnableMixedFractional
259262#if defined(AltDec_EnableImaginaryNum) || defined(AltDec_EnableENum)
260263 else if (ExtraRep>0 )
261264#else
@@ -276,12 +279,20 @@ namespace BlazesRusCode
276279 }
277280#endif
278281#if defined(AltDec_EnableImaginaryNum) || (!defined(AltDec_EnableENum)
279- else // (ExtraRep<0)Imaginary number representation doesn't exist for MediumDec
282+ #if AltDec_EnableMixedFractional
283+ else // (ExtraRep<0)
284+ #else
285+ else if (ExtraRep<0 )
286+ #endif
280287 {
281- UpdateTarget.SetVal (MediumDec::Nil);
288+ UpdateTarget.SetVal (MediumDec::Nil);// Imaginary number representation doesn't exist for MediumDec
282289 }
283290#elif defined(AltDec_EnableENum) || (!defined(AltDec_EnableImaginaryNum)
291+ #if AltDec_EnableMixedFractional
284292 else // (ExtraRep<0)
293+ #else
294+ else if (ExtraRep<0 )
295+ #endif
285296 {
286297 if (ExtraRep==-2147483647 )
287298 {
@@ -326,9 +337,13 @@ namespace BlazesRusCode
326337 }
327338#endif
328339 }
340+ #if defined(AltDec_EnableImaginaryNum) || defined(AltDec_EnableENum)
329341 else (ExtraRep>0 )
342+ #else
343+ else
344+ #endif
330345 {
331-
346+ # if AltDec_EnableMixedFractional
332347 if (DecimalHalf<0 )// Mixed Fraction
333348 {
334349 int TempAdd = IntValue;
@@ -338,8 +353,11 @@ namespace BlazesRusCode
338353 }
339354 else // Value Divided by ExtraRep
340355 {
356+ #endif
341357 MediumDec::DivOp (this , ExtraRep);
358+ #if AltDec_EnableMixedFractional
342359 }
360+ #endif
343361 }
344362#endif
345363#if defined(AltDec_EnableImaginaryNum) || (!defined(AltDec_EnableENum)
@@ -678,83 +696,86 @@ namespace BlazesRusCode
678696 {
679697 if (self.ExtraRep ==Value.ExtraRep )
680698 {
681- if (self.ExtraRep ==0 )
699+ if (self.ExtraRep ==0 ||ExtraRep==NegativeZero )
682700 {
683- if (Value .DecimalHalf == 0 )
701+ if (self .DecimalHalf < 0 ) // MixedFractional
684702 {
685- if (Value.IntValue == 0 )// (Value == Zero)
686- return self;
687- if (self.DecimalHalf == 0 )
688- {
689- self.IntValue += Value.IntValue ;
690- }
691- else
692- {
693- bool WasNegative = self.IntValue < 0 ;
694- if (WasNegative)
695- self.IntValue = self.IntValue == AltDec::NegativeZero ? -1 : --self.IntValue ;
696- self.IntValue += Value.IntValue ;
697- if (self.IntValue == -1 )
698- self.IntValue = self.DecimalHalf == 0 ? 0 : AltDec::NegativeZero;
699- else if (self.IntValue < 0 )
700- ++self.IntValue ;
701- // If flips to other side of negative, invert the decimals
702- if ((WasNegative && self.IntValue >= 0 ) || (WasNegative == 0 && self.IntValue < 0 ))
703- self.DecimalHalf = AltDec::DecimalOverflow - self.DecimalHalf ;
704- }
703+
705704 }
706705 else
707706 {
708- bool WasNegative = self.IntValue < 0 ;
709- // Deal with Int section first
710- if (WasNegative)
711- self.IntValue = self.IntValue == AltDec::NegativeZero ? -1 : --self.IntValue ;
712- if (Value.IntValue != 0 && Value.IntValue != AltDec::NegativeZero)
713- self.IntValue += Value.IntValue ;
714- // Now deal with the decimal section
715- if (Value.IntValue < 0 )
707+ if (Value.DecimalHalf == 0 )
716708 {
717- if (WasNegative)
709+ if (Value.IntValue == 0 )// (Value == Zero)
710+ return self;
711+ if (self.DecimalHalf == 0 )
718712 {
719- self.DecimalHalf += Value.DecimalHalf ;
720- if (self.DecimalHalf < 0 ) { self.DecimalHalf += AltDec::DecimalOverflow; ++self.IntValue ; }
721- else if (self.DecimalHalf >= AltDec::DecimalOverflow) { self.DecimalHalf -= AltDec::DecimalOverflow; --self.IntValue ; }
713+ self.IntValue += Value.IntValue ;
722714 }
723715 else
724716 {
725- self.DecimalHalf -= Value.DecimalHalf ;
726- if (self.DecimalHalf < 0 ) { self.DecimalHalf += AltDec::DecimalOverflow; --self.IntValue ; }
727- else if (self.DecimalHalf >= AltDec::DecimalOverflow) { self.DecimalHalf -= AltDec::DecimalOverflow; ++self.IntValue ; }
717+ bool WasNegative = self.IntValue < 0 ;
718+ if (WasNegative)
719+ self.IntValue = self.IntValue == AltDec::NegativeZero ? -1 : --self.IntValue ;
720+ self.IntValue += Value.IntValue ;
721+ if (self.IntValue == -1 )
722+ self.IntValue = self.DecimalHalf == 0 ? 0 : AltDec::NegativeZero;
723+ else if (self.IntValue < 0 )
724+ ++self.IntValue ;
725+ // If flips to other side of negative, invert the decimals
726+ if ((WasNegative && self.IntValue >= 0 ) || (WasNegative == 0 && self.IntValue < 0 ))
727+ self.DecimalHalf = AltDec::DecimalOverflow - self.DecimalHalf ;
728728 }
729729 }
730730 else
731731 {
732+ bool WasNegative = self.IntValue < 0 ;
733+ // Deal with Int section first
732734 if (WasNegative)
735+ self.IntValue = self.IntValue == AltDec::NegativeZero ? -1 : --self.IntValue ;
736+ if (Value.IntValue != 0 && Value.IntValue != AltDec::NegativeZero)
737+ self.IntValue += Value.IntValue ;
738+ // Now deal with the decimal section
739+ if (Value.IntValue < 0 )
733740 {
734- self.DecimalHalf -= Value.DecimalHalf ;
735- if (self.DecimalHalf < 0 ) { self.DecimalHalf += AltDec::DecimalOverflow; ++self.IntValue ; }
736- else if (self.DecimalHalf >= AltDec::DecimalOverflow) { self.DecimalHalf -= AltDec::DecimalOverflow; --self.IntValue ; }
741+ if (WasNegative)
742+ {
743+ self.DecimalHalf += Value.DecimalHalf ;
744+ if (self.DecimalHalf < 0 ) { self.DecimalHalf += AltDec::DecimalOverflow; ++self.IntValue ; }
745+ else if (self.DecimalHalf >= AltDec::DecimalOverflow) { self.DecimalHalf -= AltDec::DecimalOverflow; --self.IntValue ; }
746+ }
747+ else
748+ {
749+ self.DecimalHalf -= Value.DecimalHalf ;
750+ if (self.DecimalHalf < 0 ) { self.DecimalHalf += AltDec::DecimalOverflow; --self.IntValue ; }
751+ else if (self.DecimalHalf >= AltDec::DecimalOverflow) { self.DecimalHalf -= AltDec::DecimalOverflow; ++self.IntValue ; }
752+ }
737753 }
738754 else
739755 {
740- self.DecimalHalf += Value.DecimalHalf ;
741- if (self.DecimalHalf < 0 ) { self.DecimalHalf += AltDec::DecimalOverflow; --self.IntValue ; }
742- else if (self.DecimalHalf >= AltDec::DecimalOverflow) { self.DecimalHalf -= AltDec::DecimalOverflow; ++self.IntValue ; }
756+ if (WasNegative)
757+ {
758+ self.DecimalHalf -= Value.DecimalHalf ;
759+ if (self.DecimalHalf < 0 ) { self.DecimalHalf += AltDec::DecimalOverflow; ++self.IntValue ; }
760+ else if (self.DecimalHalf >= AltDec::DecimalOverflow) { self.DecimalHalf -= AltDec::DecimalOverflow; --self.IntValue ; }
761+ }
762+ else
763+ {
764+ self.DecimalHalf += Value.DecimalHalf ;
765+ if (self.DecimalHalf < 0 ) { self.DecimalHalf += AltDec::DecimalOverflow; --self.IntValue ; }
766+ else if (self.DecimalHalf >= AltDec::DecimalOverflow) { self.DecimalHalf -= AltDec::DecimalOverflow; ++self.IntValue ; }
767+ }
743768 }
769+ if (self.IntValue == -1 )
770+ self.IntValue = self.DecimalHalf == 0 ? 0 : AltDec::NegativeZero;
771+ else if (self.IntValue < 0 )
772+ ++self.IntValue ;
773+ // If flips to other side of negative, invert the decimals
774+ if ((WasNegative && self.IntValue >= 0 ) || (WasNegative == 0 && self.IntValue < 0 ))
775+ self.DecimalHalf = AltDec::DecimalOverflow - self.DecimalHalf ;
744776 }
745- if (self.IntValue == -1 )
746- self.IntValue = self.DecimalHalf == 0 ? 0 : AltDec::NegativeZero;
747- else if (self.IntValue < 0 )
748- ++self.IntValue ;
749- // If flips to other side of negative, invert the decimals
750- if ((WasNegative && self.IntValue >= 0 ) || (WasNegative == 0 && self.IntValue < 0 ))
751- self.DecimalHalf = AltDec::DecimalOverflow - self.DecimalHalf ;
752777 }
753778 }
754- else if (ExtraRep==NegativeZero)// Value*Pi Representation
755- {
756-
757- }
758779 #if defined(AltDec_EnableImaginaryNum) || defined(AltDec_EnableENum)
759780 else if (ExtraRep==RevMaxInt)
760781 {
0 commit comments