In Android Studio using Java, I'm trying to assign the value 12345678.68d to a double variable. But while running the programme, instead of the value I'm trying to assign, the system is assigning 1.234567868E7 to the variable. Surprisingly, as long as I keep the original value to the "one millionth" position, i.e. 1234567.68d, the correct value is assigned to the variable. The problem occurs as soon as I enter the "ten millionth" digit. Why is this mismatch happening?
I need to pass the actual double value to another fragment/activity where I have to display it accurately using Bundle. So, how can I make sure that a double variable takes the exact double value that I assign to it instead of converting to a weird value?
My code follows. The problem occurs at Line 5, Double dbl = 12345678.68d;
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.button1:
Double dbl = 12345678.68d;
Bundle bundle = new Bundle();
bundle.putDouble("id", dbl);
bundle.putString("name", ((EditText) this.getView().findViewById(R.id.etName)).getText().toString());
getParentFragmentManager().beginTransaction()
.setReorderingAllowed(true)
.addToBackStack(null)
.replace(R.id.fragment_container_view, SecondaryFragment.class, bundle).commit();
break;
default:
}
}