I am using BC Math
library in PHP, as you know data provided to BC functions MUST BE strings, otherwise very weird results might come out.
I am storing decimal values (18,10) in MySQL.
My questions are:
What is the type of these values when i fetch them in PHP, are they string? and can i use them directly in BC such as
bcmul($database_decimal_value , '1', '10')
?Can i use output of BC functions (which is string i guess) and insert in MySQL decimal type directly?
P.S. i have read the MySQL reference and it says: Values for DECIMAL columns no longer are represented as strings that require 1 byte per digit or sign character.
not sure if this means they are no longer strings.
Edit:
I test the answer with the following code:
<?php
$var = 0.00001;
echo bcmul('10', "$var", '5');
?>
But it echoes 0
instead of 0.00010
!
if i change $var = 0.00001
to $var = '0.00001';
(which is string) it works