Decimal.ToString()堆栈溢出异常

Decimal.ToString()

堆栈溢出异常

导致以下报错: 

A process serving application pool 'XXX' suffered a fatal communication error with the Windows Process Activation Service. The process id was '7132'. The data field contains the error number.

Application pool 'XXX' is being automatically disabled due to a series of failures in the process(es) serving that application pool.

前面的赋值等业务逻辑代码都没问题, 但是在return Json时报堆栈异常错误

后来发现是Json序列化时值与定义的类型不同, 即从数据库中读取过来的值与Model类中的字段类型不同, 例如: 数据库中的值是121-, 但是你的字段定义的是decimal, 在通过ORM框架赋值时是没问题的, 但是这种情况序列化的时候就会报异常.

var objs = ProductionOverview.GetPagedObject<ProductionOverview>(queryCondition);

            return Json(new ResultModel() { code = 0, message = "", data = objs.Source, total = objs.TotalCount }, JsonRequestBehavior.AllowGet);

这个信息也可以参考, 很专业

https://www.cnblogs.com/qidian10/p/6028784.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
import decimal def calculate_pi(): decimal.getcontext().prec = 35 pi = decimal.Decimal() k = while True: term = decimal.Decimal((-1) ** k) * (decimal.Decimal(2) ** (decimal.Decimal(5) * decimal.Decimal(k))) / (decimal.Decimal(4 * k + 1) * decimal.Decimal(math.factorial(k)) ** 2 * decimal.Decimal(396 ** (4 * k))) pi += term if abs(term) < decimal.Decimal(1e-35): break k += 1 return pi * decimal.Decimal(2 ** 6) def calculate_tan(x): decimal.getcontext().prec = 35 tan = decimal.Decimal() k = while True: term = decimal.Decimal((-1) ** k) * decimal.Decimal(2 ** (2 * k + 1)) * decimal.Decimal((2 ** (2 * k + 1) - 1)) * decimal.Decimal(x ** (2 * k + 1)) / decimal.Decimal(math.factorial(2 * k + 1)) tan += term if abs(term) < decimal.Decimal(1e-35): break k += 1 return tan def calculate_pi_with_tan(): decimal.getcontext().prec = 35 pi = decimal.Decimal() k = while True: term = decimal.Decimal((-1) ** k) * (decimal.Decimal(2) ** (decimal.Decimal(5) * decimal.Decimal(k))) / (decimal.Decimal(4 * k + 1) * decimal.Decimal(math.factorial(k)) ** 2 * decimal.Decimal(396 ** (4 * k))) * calculate_tan(decimal.Decimal(1) / decimal.Decimal(239)) pi += term if abs(term) < decimal.Decimal(1e-35): break k += 1 return pi * decimal.Decimal(2 ** 6) def kahan_sum(numbers): decimal.getcontext().prec = 35 sum = decimal.Decimal() c = decimal.Decimal() for number in numbers: y = number - c t = sum + y c = (t - sum) - y sum = t return sum pi = calculate_pi_with_tan() pi = kahan_sum([pi] * 10) print(pi) 这段代码有一些缺漏,请补充以便它计算出pi的值
03-10

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值