Если вы ищете решение на основе Ruby для этой проблемы, я рекомендую использовать метод Google Calculator для решения, аналогичного следующему: http://j.mp/QIC564
require 'faraday'
require 'faraday_middleware'
require 'json'
# Debug:
# require "pry"
country_code_src = "USD"
country_code_dst = "INR"
connection = Faraday.get("http://www.google.com/ig/calculator?hl=en&q=1#{country_code_src}=?#{country_code_dst}")
currency_comparison_hash = eval connection.body #Google's output is not JSON, it's a hash
dst_currency_value, *dst_currency_text = *currency_comparison_hash[:rhs].split(' ')
dst_currency_value = dst_currency_value.to_f
dst_currency_text = dst_currency_text.join(' ')
puts "#{country_code_dst} -> #{dst_currency_value} (#{dst_currency_text} to 1 #{country_code_src})"
Oracle BINARY_FLOAT
хранит данные внутренне с помощью IEEE 754, который делает представление с плавающей точкой, как C и много других языков. Когда Вы выбираете их от базы данных и обычно храните их в типе данных IEEE 754 на базовом языке, она может скопировать значение, не преобразовывая его.
принимая во внимание, что Oracle FLOAT
тип данных является синонимом для типа ЧИСЛОВЫХ ДАННЫХ ANSI SQL, номера вызываемого абонента в Oracle. Это - точное числовое, масштабированный тип данных decimal, который не имеет округляющегося поведения IEEE 754. Но если Вы выбираете эти значения от базы данных и помещаете их в C или плавание Java, можно потерять точность во время этого шага.
Номер Oracle является на самом деле Десятичным числом (базируйтесь 10) представление, с плавающей точкой... Плавание является просто псевдонимом для Числа и делает ту же самую вещь.
, если Вы хотите Двоичный файл (базируются 2) плавания, необходимо использовать BINARY_FLOAT Oracle или типы данных BINARY_DOUBLE.
The Oracle BINARY_FLOAT and BINARY_DOUBLE are mostly equivalent to the IEEE 754 standard but they are definitely not stored internally in the standard IEEE 754 representation.
For example, a BINARY_DOUBLE takes 9 bytes of storage vs. IEEE's 8. Also the double floating number -3.0 is represented as 3F-F7-FF-FF-FF-FF-FF-FF which if you use real IEEE would be C0-08-00-00-00-00-00-00. Notice that bit 63 is 0 in the Oracle representation while it is 1 in the IEEE one (if 's' is the sign bit, according to IEEE, the sign of the number is (-1)^s). See the very good IEEE 754 calculators at http://babbage.cs.qc.cuny.edu/IEEE-754/
You can easily find this if you have a BINARY__DOUBLE column BD in table T with the query:
select BD,DUMP(BD) from T
Now all of that is fine and interesting (maybe) but when one works in C and gets a numeric value from Oracle (by binding a variable to a numeric column of any kind), one typically gets the result in a real IEEE double as is supported by C. Now this value is subject to all of the usual IEEE inaccuracies.
If one wants to do precise arithmetic one can either do it in PL/SQL or using special precise-arithmetic C libraries.
For Oracle's own explanation of their numeric data types see: http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/datatype.htm#i16209