<div dir="ltr">I would probably use a combination of this post (<a href="http://math.stackexchange.com/questions/10173/extract-each-digit-of-a-number">http://math.stackexchange.com/questions/10173/extract-each-digit-of-a-number</a>) and the Python Decimal library for precision.<div>
<br></div><div>Another alternative that seems apparent, but I haven't put much thought into, is using the Decimal library, converting the number into a String, and grabbing the digit by index.<br><div><br></div><div>Sorry I don't have more time to give you some sample code; I have to run. If you can't solve it, I'll try to help out when I get some free time.</div>
<div><br></div><div>Good luck!</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Dec 8, 2013 at 4:10 PM, Louis Bogdan <span dir="ltr"><<a href="mailto:looiebwv@gmail.com" target="_blank">looiebwv@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>I see that there are some questions about my explanation of what I'm trying to do.  Would it clarify things if my explanation read as follows:<br>
</div>num(-1) denotes right-hand most digit of num in index position notation<br>
</div>num(-2) denotes the 3rd position digit of num in index position notation.<br><br></div>I don't know how to say it in computer language, that's why I'm asking for your help. Lou<br></div><div class="HOEnZb">
<div class="h5"><div class="gmail_extra">
<br><br><div class="gmail_quote">On Sun, Dec 8, 2013 at 2:49 PM, Brian Costlow <span dir="ltr"><<a href="mailto:brian.costlow@gmail.com" target="_blank">brian.costlow@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr">This was my quick & dirt response to an email from Louis, and Louis reply, which I have not digested yet. I pointed him at the list as I'm kind of buried with some other stuff this weekend.<div><br>

</div>
<div>You get the same rounding, will take any numeric or a string representing numeric, no float imprecision, no weird string manipulation.<br><div><br></div><div><div style="font-family:arial,sans-serif;font-size:13px">

>>> from decimal import Decimal as D</div>
<div style="font-family:arial,sans-serif;font-size:13px">>>> multiplier_val = D('2000')</div><div style="font-family:arial,sans-serif;font-size:13px">>>> quant_val = D('1')</div><div style="font-family:arial,sans-serif;font-size:13px">


>>> def custom_round(number):</div><div style="font-family:arial,sans-serif;font-size:13px">...   number = D(str(number))</div><div style="font-family:arial,sans-serif;font-size:13px">...   return (number * multiplier_val).quantize(quant_val) / multiplier_val</div>


<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><div>>>> custom_round(1.2340)</div><div>Decimal('1.234')</div><div>>>> custom_round(1.2341)</div>


<div>Decimal('1.234')</div><div>>>> custom_round(1.2342)</div><div>Decimal('1.234')</div><div>>>> custom_round(1.2343)</div><div>Decimal('1.2345')</div></div><div style="font-family:arial,sans-serif;font-size:13px">


<div>>>> custom_round(1.2346)</div><div>Decimal('1.2345')</div><div>>>> custom_round(1.2347)</div><div>Decimal('1.2345')</div><div>>>> custom_round(1.2348)</div><div>Decimal('1.235')</div>


<div>>>> custom_round(1.2349)</div></div><div style="font-family:arial,sans-serif;font-size:13px">Decimal('1.235')<br></div><div><br></div><div><div style="font-family:arial,sans-serif;font-size:13px"><div>


<div><div>  I'm so familiar with the details of my invention and its ramifications that I didn't provide you with enough details. to explain my approach. I am looking to make this a subroutine for the following reasons: <br>


</div>1. For various applications, there can be many number, N inputs.<br></div>2. For each N input, there can be as many as 30 variable incremental modifications to N, each modification requiring that "subroutine" to make sure that N is in suitable form for later usage. <br>


</div>3. The program to run this only requires the input of N and formula created range of increments thus negating any access to N variations and increments during  the cycle.<br></div><span style="font-family:arial,sans-serif;font-size:13px">4. So with this "subroutine" I have .0002" absolute positional accuracy with .0005" increment control  and other accuracies can be obtained with positional variations.  I hope this clarifies my original email.   Lou</span><br>


</div><div><br></div><div><br></div></div></div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Dec 8, 2013 at 2:36 PM, Louis Bogdan <span dir="ltr"><<a href="mailto:looiebwv@gmail.com" target="_blank">looiebwv@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div>I will start out by saying,"Have you heard that a LITTLE bit of knowledge is a dangerous thing?"  Well, I am the Poster Boy for that saying.  <br>



<br></div>num is calculated value 1.2346<br>
</div>a=num(-1) is indicating the numeral "6" with negative indexing notation.<br></div>b=num(-2) is indicating the numeral "4"   "         "            "              ".<br><br></div>



if numeral "6" is greater than "7" make numeral "6" a "0" and increment the "4" to "5".<br></div>elif numeral "6" is less than"3", meaning a "0", "1", or "2", make it a "0".<br>



</div>else none of the above conditions apply, make numeral "6" a "5".<br><br></div>EXAMPLE: 1.2340, 1.2341, 1.2342 become 1.2340<br></div>                   1.2348, 1.2349 become 1.2350<br></div>                   1.2343, 1/2344, 1.2345, 1.2346. 1.2347 become 1.2345.<br>



<br></div>So with the "Bogdan" rounding, I am never more than .0002" off calculated position.<br></div>I then divide the modified num 1.2345 by .0005 and get 2469 which is the number of steps required of the stepper motor to provide a movement of 1.2345" (-.0001" from theoretical.)  <br>



<br></div>I hope that explains MY way of talking to a computer.  How would you talk to Python and say the same thing and Python says,"MAN, I know what you want!?  Lou<br>
</div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Dec 8, 2013 at 11:34 AM, Andrew Fitzgerald <span dir="ltr"><<a href="mailto:andrewcfitzgerald@gmail.com" target="_blank">andrewcfitzgerald@gmail.com</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Lou,<div><br></div><div>Could you perhaps provide a summary of what that code is supposed to do?</div>



<div><br></div><div>Right now you're assigning num the numeric value 1.2346 on the first line.</div>
<div><br>You're then attempting to call num as a function on the next 2 lines.</div><div><br>This won't work because num hasn't been defined as a function anywhere, and if it was the function is overwritten by the value 1.2346 on the first line.</div>




<div><br></div><div><br></div><div>The part below that (if/else) looks like it should work if a and b are assigned numeric values.</div><div><br></div><div>-Andrew Fitzgerald</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">



<div><div>
On Sun, Dec 8, 2013 at 11:09 AM, Louis Bogdan <span dir="ltr"><<a href="mailto:looiebwv@gmail.com" target="_blank">looiebwv@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div><div>
<div dir="ltr">



















<p class="MsoNormal"><span style="font-size:16pt">Hi folks @central oh/python:</span></p>

<p class="MsoNormal"><span style="font-size:16pt"> </span></p>

<p class="MsoNormal"><span style="font-size:16pt">As a recent subscriber, I
received notice of your Dec 9 meeting from Brian.<span>  </span>As I am working on a program to go along with
a recently filed patent, and am totally new to Python, I sent him a proposed
“subroutine”.<span>  </span>This is used repetitively
within the program.<span>  </span>Since I sent it to
Brian, I have done some more research and have come up with a better version as
follows:</span></p>

<p class="MsoNormal"><span style="font-size:16pt"> </span></p>

<p class="MsoNormal"><span style="font-size:16pt">num = 1.2346</span></p>

<p class="MsoNormal"><span style="font-size:16pt">a = num(-1)</span></p>

<p class="MsoNormal"><span style="font-size:16pt">b = num(-2)</span></p>

<p class="MsoNormal"><span style="font-size:16pt">if a >7:</span></p>

<p class="MsoNormal"><span style="font-size:16pt"><span>     </span>a = 0</span></p>

<p class="MsoNormal"><span style="font-size:16pt"><span>     </span>b+ =1</span></p>

<p class="MsoNormal"><span style="font-size:16pt">elif a<3:</span></p>

<p class="MsoNormal"><span style="font-size:16pt"><span>     </span>a = 0</span></p>

<p class="MsoNormal"><span style="font-size:16pt">else:</span></p>

<p class="MsoNormal"><span style="font-size:16pt"><span>      </span>a = 5</span></p>

<p class="MsoNormal"><span style="font-size:16pt"> </span></p>

<p class="MsoNormal"><span style="font-size:16pt">As each stepper motor step
equals .0005” of movement, with the above I can get .0002” absolute positional
accuracy with a .0005” control increment. I have looked at some of the Python
“round” statements and examples and don’t fully understand them so as an “ole”
retired engunear, (does 93 qualify me) I thunk up my own way of doing
things.<span>  </span>Maybe some of you young ones can
teach an ole man how to do things better. </span></p>

<p class="MsoNormal"><span style="font-size:16pt"> </span></p>

<p class="MsoNormal"><span style="font-size:16pt">This routine also has
application in several other projects I have under consideration. Would something
like this, if it works, be a Python library item?<span>  </span></span></p>

<p class="MsoNormal"><span style="font-size:16pt"> </span></p>

<p class="MsoNormal"><span style="font-size:16pt">If any of you can “tweek” the
above into working order I would appreciate it.<span> 
</span>I do have some other questions for you.<span> 
</span>What do I need to buy to get started with RPi?<span>  </span>I will be using my Apple computer.</span></p>

<p class="MsoNormal"><span style="font-size:16pt"> </span></p>

<p class="MsoNormal"><span style="font-size:16pt">Thank you for any comments
you might have.<span>  </span>Lou Bigdan <span> </span></span></p>

<p class="MsoNormal"><span style="font-size:16pt"> </span></p>

<p class="MsoNormal"><span style="font-size:16pt"><span>     </span><span>  </span></span></p>





</div>
<br></div></div>_______________________________________________<br>
CentralOH mailing list<br>
<a href="mailto:CentralOH@python.org" target="_blank">CentralOH@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/centraloh" target="_blank">https://mail.python.org/mailman/listinfo/centraloh</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
CentralOH mailing list<br>
<a href="mailto:CentralOH@python.org" target="_blank">CentralOH@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/centraloh" target="_blank">https://mail.python.org/mailman/listinfo/centraloh</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
CentralOH mailing list<br>
<a href="mailto:CentralOH@python.org" target="_blank">CentralOH@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/centraloh" target="_blank">https://mail.python.org/mailman/listinfo/centraloh</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
CentralOH mailing list<br>
<a href="mailto:CentralOH@python.org" target="_blank">CentralOH@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/centraloh" target="_blank">https://mail.python.org/mailman/listinfo/centraloh</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
CentralOH mailing list<br>
<a href="mailto:CentralOH@python.org">CentralOH@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/centraloh" target="_blank">https://mail.python.org/mailman/listinfo/centraloh</a><br>
<br></blockquote></div><br></div>