Menu

multiplication Large values

Mikam
2019-02-05
2019-02-05
  • Mikam

    Mikam - 2019-02-05

    Hi
    When multiplying 232000 = 46000 'correct
    When multiplying 236
    2000 = 13248 'incorrect

    Help!

    #chip 18F45k80,64
    #option explicit
    #config OSC=INTIO2, MCLRE=OFF, WDT=OFF
    
        #include <glcd.h>
        #include <maths.h>
    
        #define GLCD_TYPE GLCD_TYPE_ILI9341
        #define GLCD_DO  portc.5       ' Data out | MOSI
        #define GLCD_SCK portc.3       ' Clock Line
        #define GLCD_DC portc.6        ' Data command line
        #define GLCD_CS portd.4        ' Chip select line
        #define GLCD_RESET portc.7     ' Reset line
      #define ILI9341_HardwareSPI    ' remove/comment out if you want to use software SPI.
    
    SPIMode Masterslow,SPI_CPOL_0 + SPI_CPHA_0
    '------------------------
    'GCB v0.98.04  2018-10-20
    '------------------------
     GLCDRotate 1
    
    dim TempSTR as String
    dim TempVal as Long
    
    'systat calculation
    dim refa as long
    dim refb as Long
    dim answer as Long
    
    'Temp sensor
    dir porta.0 in
    
    'Relays
    dir porta.1 out
    dir porta.2 out
    dir porta.3 out
    dir porta.5 out
    dir porte.0 out
    dir porte.1 out
    dir porte.2 out
    
    'switch inputs
    dir porta.7 in
    'dir porta.6 in
    dir portc.0 in
    dir portc.1 in
    dir portc.2 in
    
    'PGA2310
    dir portd.0 out  'cs
    dir portd.1 out  'mute
    
    'Remote inputs
    dir portd.6 in
    dir portd.7 in
    dir portb.1 in
    dir portb.2 in
    dir portb.3 in
    dir portb.4 in
    dir portb.5 in
    
     GLCDBackground = ILI9341_BLACK
    set porta.1 on
    set portd.1 on
    
     do Forever
     TempVAL=2000
       refa=229000
       refb=236
    
        GLCDfntDefaultSize = 2
      '  TempVAL=ReadAD12(AN0)
         GLCDDrawString (20,100,str(Tempval),ILI9341_GREEN)
         GLCDDrawString (20,125,str(refb),ILI9341_GREEN)
         answer= refb*Tempval
        TempSTR=str(answer)
        GLCDDrawString (20,150,TempSTR,ILI9341_GREEN)
    
     loop
    
     
  • Anobium

    Anobium - 2019-02-05

    Things get reported... and they seem to come at the same time.

    We resolved a similar only last week.

    May I send you a test compiler to see if this resolves the issue? Send me a Personal Message with your contact email address.

    I just tried 236*2000and got 472000 in the new compiler.

    #chip 16f877a,4
    
      'USART settings
      #define USART_BAUD_RATE 9600
      #define USART_TX_BLOCKING
    
    dim TempSTR as String
    dim TempVal as Long
    
    'systat calculation
    dim refa as long
    dim refb as Long
    dim answer as Long
    refb =236
    Tempval=2000
    answer= refb*Tempval
    
    HSerPrint answer
    
     
  • Mikam

    Mikam - 2019-02-05

    email sent.

     
    • Anobium

      Anobium - 2019-02-05

      no email. :-)

       

Log in to post a comment.