Reputation: 353
How to get 6 decimal precision using vb.net as in this example (7090982.885183 (6 decimal places precision)) i.e i want to read the .885183 in my previous sample as 6 decimal only.
The javascript for the above looks like :
//declare variables and assign calculated values
var HashA = OrdNo * Amt;
var HashB = MerchID * Amt;
var HashC = MerchID * OrdNo;
var TotalHash = String((HashA + HashB + HashC) / (parseInt(MerchID) + parseInt(RCode)));
//assign only 6 decimal places value
if (TotalHash.indexOf(".") != -1)
TotalHash = TotalHash.substr(0,TotalHash.indexOf(".")+7);
else
TotalHash = TotalHash + ".000000";
document.form1.HashCount.value = TotalHash;
}
I need to read this no 7090982.8851830000011 as this format 7090982.885183
Upvotes: 1
Views: 540
Reputation: 43023
If you have a Decimal
and you want to get the value after the decimal dot, you can do
result = input - Math.Floor(input)
Upvotes: 1
Reputation: 61
What about using % operater like
you have an variable a and variable decimalresult you should code it like this
decimalresult=a % 1000000
In this example it should be
decimalresult= 7090982.885183 % 1000000
decimalresult = 885183
Upvotes: 1