How to display large numbers


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Red face

    Opps - on the comment in the above code snippet ....

    is:
    ' take 4*65536+55296 = 4*(65000+536)+55296 = 4*65000+4*536+55296
    ' the 4*65000 term does not contribute to the low 3 digits so leave it out

    was:
    ' take 4*65536+55296 = 4*(6200+536)+55296 = 4*62000+4*536+55296
    ' the 4*62000 term does not contribute to the low 3 digits so leave it out


    I need more coffee - paul

  2. #2
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Default

    OK,

    32-bit-arithemtik,
    sometimes I'm happy to have learned the basics of our job (on a pdp/8 with 12-bit-words an silly switches and lamps on the front).

    Div-by-10 ... uuuh ... I feel sleepy!

    $7FFFFFFF is decimal 2147483647 .... uuuh, the big one !

    I think, you will deal with 7-count numbers....
    Just look, if the number is bigger then 999999:

    Flag=0
    if High_Word>$F Then Flag=1
    if High_Word=$F AND Low_Word>$423F Then Flag=1

    If it is bigger, count how often by subtracting 1000000 !

    Ct=0
    If Flag Then
    Repeat
    If Low_Word<$4240 Then High_Word=High_Word-1
    Low_Word=Low_Word-$4240:Ct=Ct+1
    [...] copy **** from above
    Until Flag=0
    Endif

    You got an digit ! Just Store or print it ! (LCDWRITE "0"+Ct)
    Multiply the rest by 10 !

    Gosub Rotate32 (x2)
    High_Copy=High_Byte:Low_Copy=Low_Byte
    Gosub Rotate32:Gosub Rotate32 (all together x8)
    High_Word=High_Word+High_Copy
    If Low_Word.15 AND Low_Copy.15 Then High_Word=High_Word+1:Low_Word.15=0:Low_Copy.15=0
    Flag=Low_Word.15 or Low_Copy.15
    Low_Word=Low_Word+Low_Copy:If Flag AND (Low_Word.15=0) Then High_Word=High_Word+1

    Rotate32:
    High_Word=High_Word<<1:If Low_Word.15 Then High_Word.0=1
    Low_Word=Low_Word<<1:Return

    uuuuh ... with assembler its much smoother because of the carry-flag.


    Repeat it seven times !
    Go sleep!
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

Similar Threads

  1. Hdsp 21xx display
    By Original in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th June 2012, 21:07
  2. LARGE 40x4 LCD Display
    By Art in forum Adverts
    Replies: 3
    Last Post: - 15th December 2008, 10:19
  3. Replies: 14
    Last Post: - 26th September 2007, 06:41
  4. store/display very large numbers (700000)
    By ttease in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th March 2007, 23:08
  5. Multiplying large numbers
    By jhonea1 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 14th April 2006, 18:41

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