[CentralOH] Say What You Want To Accomplish

jep200404 at columbus.rr.com jep200404 at columbus.rr.com
Sun Dec 8 21:00:07 CET 2013


On Sun, 8 Dec 2013 14:36:01 -0500, Louis Bogdan <looiebwv at gmail.com> wrote:

> if numeral "6" is greater than "7" make numeral "6" a "0" and increment the
> "4" to "5".
> elif numeral "6" is less than"3", meaning a "0", "1", or "2", make it a "0".
> else none of the above conditions apply, make numeral "6" a "5".

Uggh! 

There is a simple problem with a simple solution hiding in 
the above. 

Tell us what you want to accomplish in prose, 
without magic numbers, without suggesting implementations. 
Do not overthink it. 
Name the quantities. 
If those are not the right terms, use the right ones. 

Tell us about the hardware. 
What are its capabilities?
What are its limitations?

> if numeral "6" is greater than "7" ...

"6" is greater than "7" for sufficiently large values of "6". :-)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

step_resolution = 0.0005  # Unit is one inch.

def closest(x, resolution):
    return round(x / resolution) * resolution

for x in range(10 + 1):
    x = (12340 + x) / 10000.0
    print x, closest(x, step_resolution)



More information about the CentralOH mailing list