Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2004
    Thanked 0 Times in 0 Posts

    Question Unsigned variables?

    I'm using Javascript calls to a backend video control application (not written by me). That's working fine but I'm having trouble with this...

    One of the calls returns an unsigned 32-bit value. This value is the duration of the video. If the video is actually playing, it sets bit 31.

    When I try this out, I'll get the following number in the Javascript:

    2147483660 which is of course 0x8000000C. It also means that the video is 12 seconds in duration and is playing.

    Now I'd have thought that by doing the following, I could filter out the bit and find out the duration of the video:

    duration &= 0x80000000;

    But when I come to look at "duration", it comes out as 0 everytime.

    Is this to do with the variable "duration"? Is there a way of saying that a variable is unsigned?

    Cheers for any help,


  2. #2
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    72░ W. 48' 57" , 41░ N. 32' 04"
    Thanked 1 Time in 1 Post
    Shark, when i'm testing this, it's coming out as -2147483648 everytime. is there anything else that you're doing, that might be making it come out as 0?

    also, the only way that i know of to make something unsigned in JavaScript, is to pass it through Math.abs() .
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  3. #3
    Master Coder
    Join Date
    Feb 2003
    Umeň, Sweden
    Thanked 83 Times in 74 Posts
    Sorry, but JavaScript uses double precision floating point for storing numbers. Bitwise actions convert the numbers to a 32 bit signed integer when working, then converts the result back to float. So, there's no way of getting unsigned integers. You'll have to work with floating point math.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts