0

To clarify: I'm creating a computer program and I'm trying to find the actual mathematical way of approaching my problem. Given a number x, a is 0.7x. After doing some testing, it seems that to get back up to x from a, I can multiply by 1.42857143, but sometimes this isn't enough precision and gets a number that is very wrong.

Is there a blatantly obvious solution to this that I can't see? I want to find a better way to solve this without repeatedly adding 1 until it's right.

Thanks!

Emily
  • 11

2 Answers2

1

Precision of operations is limited on computers.

What data type do you use? Float? Double?

To get better precision, you may want to use the types like BigDecimal.

If this is not sufficient, use other tools for programming like Mathematica.

1

Ooooookay so it looks like I'm an idiot. 1.42857143 is 10÷7, and somehow I didn't notice that. I can simply just repeat the value if I want more precision.

Emily
  • 11