Shop OBEX P1 Docs P2 Docs Learn Events
taking 1.5% of a variable — Parallax Forums

taking 1.5% of a variable

ArchiverArchiver Posts: 46,084
edited 2003-07-16 00:34 in General Discussion
I need to be able to take 1.5% of a 16bit variable but X*.015 does not work

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-07-15 18:16
    >I need to be able to take 1.5% of a 16bit variable but X*.015 does not work

    Y = X ** 983 ' to 1% of X
    debug dec y,cr

    or,

    Y = X ** 9831 ' to 0.1%
    debug dec y/10,".",dec1 y,cr

    or
    Y = X ** 49152 ' to 0.02%
    debug dec y/50,".",dec2 y//50*2,cr


    -- best regards
    Tracy Allen
    electronically monitored ecosystems
    http://www.emesystems.com
    mailto:tracy@e...
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-15 19:08
    --- In basicstamps@yahoogroups.com, "FalconWireless Tech Support -
    KF4HAZ" <techsupport@f...> wrote:
    > I need to be able to take 1.5% of a 16bit variable but X*.015 does
    not work


    yikes !

    I deal with instruments that have 1.5% error in some cases.

    that would make trying to measure 1.5% of the sensor output
    (variable) equal to the expected reading. or, 100% error.

    Dave
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-16 00:07
    Someone check me on this, as it definitely depends upon the value of X.
    In general, however, you want to multiply X by 15 and then divide by
    1000, unless that would make 15 X too big. Then you might try to divide
    by 1000 and then multiply by 15. I think you get the idea. Decimals are
    not available.


    On Tuesday, July 15, 2003, at 11:57 AM, FalconWireless Tech Support -
    KF4HAZ wrote:

    > I need to be able to take 1.5% of a 16bit variable but X*.015 does not
    > work
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject
    > and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-16 00:34
    Thanks for the integer tutorial.

    On Tuesday, July 15, 2003, at 07:07 PM, Mark Marpet wrote:

    > Someone check me on this, as it definitely depends upon the value of X.
    > In general, however, you want to multiply X by 15 and then divide by
    > 1000, unless that would make 15 X too big. Then you might try to divide
    > by 1000 and then multiply by 15. I think you get the idea. Decimals are
    > not available.
    >
    >
    > On Tuesday, July 15, 2003, at 11:57 AM, FalconWireless Tech Support -
    > KF4HAZ wrote:
    >
    >> I need to be able to take 1.5% of a 16bit variable but X*.015 does not
    >> work
    >>
    >>
    >> To UNSUBSCRIBE, just send mail to:
    >> basicstamps-unsubscribe@yahoogroups.com
    >> from the same email address that you subscribed. Text in the Subject
    >> and Body of the message will be ignored.
    >>
    >>
    >> Your use of Yahoo! Groups is subject to
    >> http://docs.yahoo.com/info/terms/
    >>
    >>
    >>
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject
    > and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
    >
    >
Sign In or Register to comment.