Ohms law basic calculations for calculating R2 in voltage divider when R1 is known and to calculate voltage drop ratio when both R1 and R2 are known.

Revision:
2:1c29960a42c6
Parent:
0:fe642275688d
--- a/ohms.cpp	Fri Jul 15 13:46:38 2016 +0000
+++ b/ohms.cpp	Thu Aug 04 06:23:43 2016 +0000
@@ -3,10 +3,10 @@
  
 
 float volDivideCalcRatio(long r1, long r2) {
-  return ((float) r2 / (float) (r1 + r2));
+  return (float) ((double) r2 / (double) (r1 + r2));
 }
 float voltDivideAdjVolt(float vin, long r1, long r2) {
-  float ratio = ((float) r2 / (float) (r1 + r2));
+  float ratio = volDivideCalcRatio(r1, r2);
   return vin / ratio;
 }