Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Divide a number
Message
 
To
24/01/1999 08:49:55
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00179550
Message ID:
00179570
Views:
17
Hi John,

nSteps= int(nArc/nAngle)
nAngle1= nArc/nSteps

in your example, nSteps= 153, nArc= 360 and nAngle= 2.347678. nAngle1= 2.352941.

nAngle1 being the corrected angle.

Now assuming you work with numerics with 6 behind the decimal point, you could do the following
nSteps0= int(nArc/nAngle)
lFlipFlop= .t.
n= 0
do while .t.
   nSteps= iif(lFlipflop,n,-n)
   if nSteps= 0  &&  we hope this won't happen :)
       error
   endif
   nAngle1= nArc/nSteps
   if abs(nArc-nSteps*nAngle1)<0.000001
       exit && nSteps and nAngle1 are the information you're looking for
   endif
   lFlipflop= !lFlipflop
   if !lFlipFlop
      n= n+1
   endif

enddo
This way you will try 153, 152, 154, 155 until you find that the product of nSteps and nAngle1 come within the range you want.

HTH,

Marc

>I need to figure out how to divide a number and not have a remainder. I can decrease the divisor by small amounts until it will go evenly. I would like to stay within 6 decmil places. The number I divide will between 0.000001 and 360.000000. The divisor will always be less than 1/4 of the number being divided.
>
>For example my arc is 360.000000 degrees and the angle is 10.00000. This will give me exactly 36 steps for the circle. So if I have an arc of 360.000000 and an angle of 2.347678 I get 153.343005 steps. If I round the steps to 153 I get 2.352941 degrees per step. If I then multiply the step angle by the steps I get less than 360 degrees which is the final angle. The step angle must end up at he final angle exactly.
>
>360.000000 / 2.347678 = 153.343005 Steps
>360.000000 / 153 = 2.352941 Degrees per step
>153 * 2.352941 = 359.999973 Final angle
>
>Thanks for any help

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Previous
Reply
Map
View

Click here to load this message in the networking platform