简体   繁体   English

将浮点(双精度)从Java转换为JRuby on Rails到SQL

[英]Converting floating point (double) from Java to JRuby on Rails to SQL

I am writing a library in Java so I can use it in JRuby on Rails with a MySQL database. 我正在用Java编写一个库,因此可以在JRuby on Rails中将它与MySQL数据库一起使用。 Should I use float or double to represent the floating point that is eventually going to end up as the :decimal model type in Rails ActiveRecord? 我应该使用float还是double来表示浮点,这些浮点最终会在Rails ActiveRecord中成为:decimal模型类型?

More explicitly: 更明确地说:

  • double converts to a DOUBLE PRECISION 双精度转换为双精度

  • float converts to a FLOAT float转换为FLOAT

But since only :decimal is supported in ActiveRecord , which Java primitive maps to that? 但是由于ActiveRecord支持 :decimal ,因此哪个Java原语映射到该:decimal

The equivalent in Java is the BigDecimal class. Java中的等效项是BigDecimal类。 There is no primitive for this. 没有原始的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM