Skip to main content
Visitor II
January 18, 2007
Question

conversion problem..

  • January 18, 2007
  • 2 replies
  • 890 views
Posted on January 18, 2007 at 15:13

conversion problem..

    This topic has been closed for replies.

    2 replies

    ariAuthor
    Visitor II
    January 18, 2007
    Posted on January 18, 2007 at 11:38

    i'm sure there is some simple mistake in this, but i just cannot see it. the problem is that i'm trying to convert seconds to hours as follows - and it just doesn't seem to work.. please help.

    hours = (int) ((unsigned long) (byte1 | byte2<

    bytes contain the seconds value - and the result should be stored as int. simple, but just cannot get it working!

    ariAuthor
    Visitor II
    January 18, 2007
    Posted on January 18, 2007 at 15:13

    Found it probably - have to test on CPU though, but at least it now makes more sense and there shouldn't be any casting mistakes anymore.. or?

    // create seconds counter contents (125000s)

    byte1 = 0x48;

    byte2 = 0xe8;

    byte3 = 0x01;

    byte4 = 0;

    // should result 34h -->

    i = (int) (

    ( (unsigned long) byte1

    + (unsigned long) byte2 * 256L

    + (unsigned long) byte3 * 65536L

    + (unsigned long) byte4 * 16777216L )

    / 3600L

    );