I need to divide an Integer by 2048 and display as a decimal

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
Richard
Posts: 9
Joined: Sun Jan 10, 2016 7:18 pm
Has thanked: 2 times
Been thanked: 4 times
Contact:

I need to divide an Integer by 2048 and display as a decimal

Post by Richard »

Hi,

I am sampling an accelerometer and placing the result in an integer (AccelMax).

The accelerometer represents 0 G's as 0 counts, and 16 G's as 32767 (2048 counts per G)

If I just divide the integer (AccelMax) by 2048, it rounds it off down to the nearest whole integer. I need to be able to show at least 2 decimal places. I'm not sure where to go from here. Any help is appreciated. Thanks.

Richard

Richard
Posts: 9
Joined: Sun Jan 10, 2016 7:18 pm
Has thanked: 2 times
Been thanked: 4 times
Contact:

Re: I need to divide an Integer by 2048 and display as a dec

Post by Richard »

I figured out how to do it, only using integers.

I created 3 loops, one to figure out the whole number, passed on the remainder, one for the tenths, passed on the remainder, and one for the hundredths. Once I figured it out, it is quite simple (what isn't), and can be used for any base number to be divided by, and any number of decimal places, just change the number you subtract, and add more loops.

I have included my program for others.

Richard
Attachments
Convert Integer to Decimal Number.fcfx
(8.91 KiB) Downloaded 197 times

Post Reply