Round the clock


Closed Thread
Results 1 to 28 of 28

Thread: Round the clock

Hybrid View

  1. #1
    Join Date
    Jan 2013
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: Round the clock

    Quote Originally Posted by Ioannis View Post
    The hand can do the round, but your variable can hold whatever value. Also with Mod 12 you still have the 12h basis value.

    Ioannis
    Hi I,

    I don't understand your answer, can you explain what MOD 12 is please?

    C.

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,133


    Did you find this post helpful? Yes | No

    Default Re: Round the clock

    Modulus division. You divide by 12 and keep the as a result the integer remainder of the division.

    So 23.00 h mod 12 gives remaider 11, exactly what 23 at 12h basis is.

    Ioannis

  3. #3
    Join Date
    Jan 2013
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: Round the clock

    Quote Originally Posted by Ioannis View Post
    Modulus division. You divide by 12 and keep the as a result the integer remainder of the division.

    So 23.00 h mod 12 gives remaider 11, exactly what 23 at 12h basis is.

    Ioannis
    Hi I,

    I'm not so good at Maths, so please make allowances

    I have to read instructions a number of times to 'get it'. In this line is there a word missing? [You divide by 12 and keep the=== as a result the integer remainder of the division.]

    As mentioned, I'm programming a PIC and I just looked at the Oshonsoft manual, here is a paragraph:
    Five arithmetic operations (+, -, *, /, MOD) are available for integer data types. MOD operation is not applicable for Single data type variables. The compiler is able to compile all possible complex arithmetic expressions, including those containing math functions and user defined functions. For example:
    Dim i As Word
    Dim j As Word
    Dim x As Word
    i = 123
    j = i * 234
    x = 2
    x = (j * x - 12345) / (i + x)

    From my reading, and as I'm using SINGLEs, this means I can't use MOD. If so is there another way? (SINGLEs allow 0.0000000)

    C.
    Last edited by camerart; - 22nd January 2016 at 10:13.

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,133


    Did you find this post helpful? Yes | No

    Default Re: Round the clock

    I have not used the Oshonsoft compiler yet, although I have it.

    But nothing bothers you to use a Word variable instead of the Single.

    I wrote my post in succesive interruptions because of phone calls and other tasks, so yes, the word "the" should be deleted.

    Ioannis

  5. #5
    Join Date
    Jan 2013
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: Round the clock

    Quote Originally Posted by Ioannis View Post
    I have not used the Oshonsoft compiler yet, although I have it.

    But nothing bothers you to use a Word variable instead of the Single.

    I wrote my post in succesive interruptions because of phone calls and other tasks, so yes, the word "the" should be deleted.

    Ioannis
    Hi I,

    Oshonsoft is a good simulator for me, although it does have faults.

    I need the SINGLE in the equation as it can cope with precision 0.0000000 calculations, WORD won't work.

    C.

  6. #6
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: Round the clock

    I do not follow the conversation well enough to speak in context, but in doing a similar thing I found the solution to calculate direction and distance separately; then, once I'd accurately calculated these, dump off those variables to a routine that "swung the needle". I did not need to worry about "round" however as I was programming to mimic analog gauges.

    Last, to simulate MOD subtract the integer value from the single value - that decimal portion which remains...
    Last edited by Amoque; - 22nd January 2016 at 13:48.

  7. #7
    Join Date
    Jan 2013
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: Round the clock

    Quote Originally Posted by Amoque View Post
    I do not follow the conversation well enough to speak in context, but in doing a similar thing I found the solution to calculate direction and distance separately; then, once I'd accurately calculated these, dump off those variables to a routine that "swung the needle". I did not need to worry about "round" however as I was programming to mimic analog gauges.

    Last, to simulate MOD subtract the integer value from the single value - that decimal portion which remains...
    Hi A,

    Here's another explanation, again using the clock:

    1/ The HAND is at 3. Input FACE 5. HAND<FACE = cwise. HAND moves and counts. HAND=4. HAND<FACE=cwise. HAND moves and counts. HAND=5. HAND=FACE =BRAKE.

    2/ The HAND is at 12. Input FACE=1 HAND>FACE = ccwise NOT CORRECT.

    I want FACE to cover FACE+1 and FACE-1.

    3/ The HAND is at 12. Input FACE=1 Now FACE-1= -1.

    This is difficult for me to understand.

    I am also trying to understand the MOD suggestions. I will need to check the program to see if I can use MOD, as I get to understand it more.

    Thanks. C.

    C.
    Last edited by camerart; - 22nd January 2016 at 14:38.

Similar Threads

  1. DT_INT Vs ASM - Round 1
    By Megahertz in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 27th January 2013, 21:33
  2. How to round number using integer only
    By Yvesmazzon in forum Code Examples
    Replies: 2
    Last Post: - 6th March 2011, 13:37
  3. external clock / internal clock
    By grounded in forum General
    Replies: 4
    Last Post: - 31st May 2008, 17:44
  4. Clock
    By Fredrick in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st February 2008, 02:23
  5. Round Dial, Electronic Combination Lock
    By Pic_User in forum Off Topic
    Replies: 5
    Last Post: - 6th July 2006, 13:34

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts