'DIG' equivalent in other Languages?


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2003
    Posts
    985

    Default 'DIG' equivalent in other Languages?

    Hi Guys,
    Just wondering if there's a way to do it in C or LUA, or any other language
    for that matter.
    Forgive me if it is off topic getting into another platform but the problem
    is I am trying to convert BASIC code that uses this operator.

    Now I have a number that is limited to three digits (max '999'),
    and need to load each digit into seperate variables so they
    can each be printed as seperate numbers that each range from 0 to 9.

    Would the compiler divide it all down and throw away the remainders?
    It seems a bit time consuming of the pic to do it that way.
    Cheers, Art.
    Last edited by Art; - 27th November 2005 at 05:04.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    DIG just divides the number by 10 and returns the remainder.

    Example. Say you want to extract digits 0, 1, and 2 from 102.

    102/10 = 10.2 <-- DIG 0 = 2
    10/10 = 1.0 <-- DIG 1 = 0
    1/10 = 0.1 <-- DIG 2 = 1

    Pretty simple stuff to do with any language.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default

    hehe..
    It wasn't easy for pic basic to do it in asm

    but you are right, and I was making it a bigger problem than it is
    I think the language I'm using can have decimal numbers placed in variables.
    Art.
    Last edited by Art; - 27th November 2005 at 23:43.

Similar Threads

  1. NMEA CheckSum Routine
    By Tom Gonser in forum Code Examples
    Replies: 2
    Last Post: - 6th June 2015, 22:24
  2. PIC16f877 code crosses boundary @800h
    By inventosrl in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th April 2009, 22:03
  3. DIG DEC Madness
    By earltyso in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 13th June 2008, 23:05
  4. Rc int on 16f874
    By hakan in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 15th July 2007, 18:57
  5. LCDout Command causes Interrupt!!??
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 31st March 2005, 04:18

Members who have read this thread : 1

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