Announcement

Collapse

Maintenance

The forum could be offline for 30-60 minutes in the very near future for maintenance (said 3pm Pacific). I was behind on getting this notice. I do apologize.
See more
See less

Fuzzy Math

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Fuzzy Math

    Im doing simple division (moving the decimal place) for my Date to Julian Function (thanks Lance) and I found a bug which I traced down to this (run example)

    Could someone tell what the heck is going on?

    #COMPILE EXE "Fuzzy.exe"

    GLOBAL Date AS LONG
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤'
    FUNCTION PBMAIN

    Date = 991209

    ' Year& = 1900 + Date/10000
    ' Month& = FIX((Date/10000 - FIX(Date/10000))*100)
    ' Day& = FIX((Date/100 - FIX(Date/100)) *100)

    MSGBOX( "( "+STR$(Date/100)+" - "+STR$(FIX(Date/100))+" ) * 100 = "+STR$(FIX((Date/100 - FIX(Date/100))*100))+" !!!" )

    END FUNCTION
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤'

    ------------------
    Kind Regards
    Mike

  • #2
    Try :

    Code:
    LOCAL Remainder AS DOUBLE
    LOCAL Result AS DOUBLE
    
    
    Result = Date/100
    Remainder = Result - FIX(Result)
    MSGBOX "FIX( "+STR$(Remainder* 100)+") = " + STR$( FIX(Remainder* 100) )

    ------------------
    Bernard Ertl

    [This message has been edited by Bern Ertl (edited March 05, 2001).]
    Bernard Ertl
    InterPlan Systems

    Comment


    • #3
      Result = Date/100
      Remainder = Result - FIX(Result)
      OR:
      Code:
      Result = Date\ 100            ' integer divide "\"
      Remainder = Result MOD 100
      MCM

      Michael Mattias
      Tal Systems Inc. (retired)
      Racine WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        aaaaaaaaaaaaaaaah! Integer division and MODulo. I get it. thx so much guys

        ------------------
        Kind Regards
        Mike

        Comment

        Working...
        X