public IActionResult Pi(DoublePrecision precision) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } else { return(Ok(_mathService.Pi(precision.Digits))); } }
public void Execute(ushort K0) { // find previous address var K1 = (ushort)(K0 - 1); // read DP values from registers and memroy var dp1 = new DoublePrecision(CPU.A.Read(), CPU.L.Read()); var dp2 = new DoublePrecision(CPU.Memory[K1], CPU.Memory[K0]); // create sum var sum = dp1 + dp2; // calculate A and L result values first, // this handles the case for when K0 is the L register // L always cleared to +0 CPU.L.Write(OnesCompliment.PositiveZero); // A set based upon overflow if (sum.MostSignificantWord.IsPositiveOverflow) { CPU.A.Write(OnesCompliment.PositiveOne); } else if (sum.MostSignificantWord.IsNegativeOverflow) { CPU.A.Write(OnesCompliment.NegativeOne); } else { CPU.A.Write(OnesCompliment.PositiveZero); } // store result in memory CPU.Memory[K1] = sum.MostSignificantWord; CPU.Memory[K0] = sum.LeastSignificantWord; }