Shop OBEX P1 Docs P2 Docs Learn Events
Problem dividing decimal — Parallax Forums

Problem dividing decimal

MarsMars Posts: 1
edited 2006-10-03 21:29 in BASIC Stamp
Hi

I'm trying to divide a decimal number and it just doesnt give the correct answer...

This is what I have:

IF (SEQU=2)THEN
· COUNTER=DEG/(15/4)
ELSE
· COUNTER=DEG/(15/2)
ENDIF

I'm trying to divide the variable DEG with 3.75, first of all, it won't let me divide it by 3.75, so I tried dividing it by (15/4) and still doesnt work, so what I did is:

COUNTER=DEG*/68 and still wont get the right answer........I· had 68 because, 1/3.75 = .26666 and that multiplied by 256 gives 68.

Anyone?

Thx

Comments

  • NewzedNewzed Posts: 2,503
    edited 2006-10-03 21:29
    Dividing by 3.75 is the same as multiplying by .266.· .266 = $44.

    Let's take 70 degrees.·

    a = (70*100)*/$0044 = 1859

    DEBUG dec a/100, ".", dec2 a, cr

    This will display 18.59.· This is an error of· .3 percent.· Close enough?

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Need a TV Module?

    Newzed@aol.com
    ·
Sign In or Register to comment.