Converting jlong to unsigned long

Hi Everyone,
I am calling a interface from a dll file which need a unsigned long or long as a parameter. In the C program side, how can I convert the jlong to unsigned long or long and then call the interface from the dll file? Also, how can I convert the long back to jlong and return back to Java side? Thank you.
Jacky

Straight cast - BigInteger would be overkill.

Similar Messages

  • How to convert double to unsigned long integer for cRIO analog output?

    All,
    Having issues sending out my arbitrary waveform to my cRIO analog output. My values are doubles and by the time I send them out, they have been converted to U32 values and are all turning out as zeroes. This led me to assume two things: 1) That cRIO analog output can only output integers since the values need to be deployed in the memory first and 2) that I'm missing a step in the conversion process. My values range from 0-8, therefore I don't expect that the simple conversion tool in labview should make everything into zeroes.
    Any help?

    Since we are using the cRIO's FPGA interface, you really should be doing most of this inside of the FPGA.  Use DMA FIFOs to pass your data between your RT and the FPGA (and visa versa).
    On your FPGA, you can have a loop that just reads the analog inputs at whatever loop rate you want.  You just send the data to the RT using a DMA.
    Similarly, use a DMA to send your analog output values to the FPGA.  The FPGA can have another loop that reads the DMA and writes the value to the analog output.  This should be done in the FPGA since you can have the FPGA send out the values at a given (and deterministic) loop rate.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Converting a Wide String to unsigned long long?

    Hi there,
    I am looking for a way to convert a string to unsigned long long on
    Solaris. On AIX and Linux, there is wcstoull. However, I do not find
    that in solaris. So, I plan to use swscanf ( str, L"%llu", &val).
    However, running thru Rational Purify, each call to swscanf leaks 1
    byte.
    Anyone has a 3rd solution other than the two above? Or maybe there
    is fix to the swscanf leak?
    Thanks in advance,
    Miranda

    % man -s 3C strtoull

  • Unsigned Long in java

    Hi all,
    I have a code in C which i want to convert into java.. Iam facing problem because java does not support
    unsigned long.The code in c look like this:
    WCD.cardno = ( SerBuf[3]* 0x00010000UL+
    SerBuf[4]* 0x00000100UL+
    SerBuf[5]* 0x00000001UL);
    I want to convert this code into java. What i have done is something like this
    cardno = (tempBuffer[3]*0x01000000 + tempBuffer[4]*0x00010000 + tempBuffer[5]*0x00000100 +tempBuffer[6]*0x00000001);
    Can anyone help me out. This program is for serial port implementation.
    Thanks
    Kiran

    kiranJNI wrote:
    Basically how can we achieve unsigned long in java???In your case, this isn't going to be a problem for two reasons.
    AFAIK, there aren't any numbers where multiplying them as unsigned numbers is going to be different from multiplying them as signed numbers and still give a valid result. To make this easier, let's work with signed vs unsigned bytes. Negative numbers are those in the range 0x80 to 0xFF; these are the only numbers where the "value" of the byte differs between signed and unsigned. Now think of those numbers as unsigned numbers. The only unsigned numbers you could multiply them by and still remain within the range of a byte are 0 and 1. If you multiply by 2, the result is 0x100, which is larger than what a byte can represent. If the result will remain within the range of the data type, it don't think there are any numbers where signed and unsigned multiplication return a different bit pattern.
    Furthermore, your example doesn't even need multiplication. You're multiplying by powers of 2, so all you really need is a series of shifts and adds.

  • Taking an array of unsigned word an using it in a subVI that accepts an unsigned long

    I have a user specified sized array that is in unsigned word(16bit). I need to use a subVI, but the subVI only accepts unsigned long(32bit). I was wondering if anyone would know how to make this work.

    Hi Amy;
    Unless I am missing something, there should not be any problem inside LabVIEW.
    To play it safe and keep LabVIEW performance up, convert the array using the "To Unsigned Long Integer" vi located in the function palette:
    Numeric -> Conversion
    Regards;
    Enrique
    www.vartortech.com

  • Should using unsigned long long be this difficult?

    So I have a number. Possibly a big number that I would like to use. When I do the following, valueToGet is fine (1252904880010) when it returns but when I step to currentTimeStamp the value is something like 18446744072483981194.
    I can only assume that maybe I am missing some basic understanding of how methods return this value.
    -(void)processTimestampReceived
    NSString* timeString = @"1252904880010";
    unsigned long long currentTimestamp = [self getUnsignedLongLong: timeString];
    NSLog(@"currentTimeStamp (converted from timeString): %qu", currentTimestamp);
    -(unsigned long long)getUnsignedLongLong:(NSString*)longString
    NSScanner* scanner = [NSScanner scannerWithString:longString];
    unsigned long long valueToGet;
    if([scanner scanLongLong:&valueToGet] == YES) {
    return valueToGet;
    return -1;

    That is so discouraging that code that SHOULD work actually does work for everyone but me. Here is the data after I changed the following code. I had to use scanHexLongLong to actually return an unsigned long long instead of just long long. Is it possible that maybe something is just stomping on that memory location somehow and giving me bad data? But consistently the same way? Seems odd.
    2009-09-14 02:36:37.325 TestApp[46744:20b] lVal=322333076619280
    2009-09-14 02:36:37.530 TestApp[46744:20b] currentTimeStamp (converted from timeString): 322333076619280
    Run using:
    [self processTimestampReceived];
    unsigned long long lVal = [self getUnsignedLongLong:@"1252904880010"];
    NSLog(@"lVal=%qu", lVal);
    -(void)processTimestampReceived
    NSString* timeString = @"1252904880010";
    unsigned long long currentTimestamp = [self getUnsignedLongLong: timeString];
    NSLog(@"currentTimeStamp (converted from timeString): %qu", currentTimestamp);
    -(unsigned long long)getUnsignedLongLong:(NSString*)longString
    NSScanner* scanner = [NSScanner scannerWithString:longString];
    unsigned long long valueToGet;
    if([scanner scanHexLongLong:&valueToGet] == YES) {
    return valueToGet;
    return -1;

  • Parsing binary file- unsigned longs

    Hello everyone.
    I'm currently trying to write a quick parser for a binary file format (ASF). However, java's handling of bit shifting and lack of unsigned types is driving me completely mad.
    How can I represent an unsigned long?
    How can I set the bits for it anyway? It seems that the shift operator can't shift more than an int's worth (it just loops around and starts adding to the other bits- weird).
    Thanks in advance.
    Simon

    ejp wrote:
    But why in the world does the following code also do nothing?
    long x = 45 << 32;
    Try long x = 45L << 32;
    The answer appears to be that java uses ints to represent all constants, but this presents some serious problems- namely- how on earth do you get a number bigger than an int into a long?With 'L'. Same as in C or C++. In Visual Basic it's '&'. There's generally something.Where did that come from? Why have I never seen anything like that before?
    If I do long x = 0x7FFFFFFF; all is well, but if I do long x = 0x80000000; I get FFFFFFFF80000000, which isn't what I asked for.Actually it is exactly what you asked for. You've overlooked several facts: (i) Java longs are 64 bits; (ii) you specified a negative 32-bit constant; (iii) the rules of every programming language I can think of provide for sign-extension when going from a shorter to a longer type.Right. It makes sense now that I know how to specify long constants.
    As someone pointed out signed/unsigned is actually the same, so long as you interpret it correctly. So to avoid the total stupidity of using twice as much memory for everything I've decided that I am actually going to use the correct types.They're not the correct types. As I pointed out in an earlier post, your 'unsigned longs' must be coming from C or C++ where they are generally 32 bits, so using a 64-bit Java long is incorrect.Where they came from doesn't matter. The spec doesn't say it's a "long"- it says that this particular value is 64bit, and that all values are unsigned. So I do need a Java long.
    WHY IN THE WORLD IS JAVA "INTELLIGENT" WHEN DOING THINGS BITWISE? WHICH BRAIN DEAD IDIOT THOUGHT THAT UP? That is broken and is asking for trouble.It is you who is asking for trouble here. The rules of Java are consistent and in conformity with the practice in other programming languages. You've just overlooked several relevant facts.I think I've worked out where I was going wrong here. When doing something like
    int i;
    long x;
    x = x | i;The i is converted to a long before the bitwise operation, so it's not the bitwise operation that's the problem, it's the conversion between int and long?
    It's not Java whose stupidity is the issue here ;-)That wouldn't surprise me.
    Thanks.

  • Signature: FSUpdateOperationStatus(void const*, TCountedPtr TCFURLInfo const&, long long, long long, long long, long long, unsigned long). No support Docs on file for this problem. Multiple crashes on opening Firefax. Running OSX 10.6.4.

    Signature:
    FSUpdateOperationStatus(void const*, TCountedPtr<TCFURLInfo> const&, long long, long long, long long, long long, unsigned long)
    No Support Docs on File.
    Firefox crashes every time it is opened.
    UUID 38fc1438-492f-4ce3-91d4-5ef922101027
    Time 2010-10-27 11:19:32.620395
    Uptime 11
    Last Crash 110 seconds before submission
    Install Age 610295 seconds (1.0 weeks) since version was first installed.
    Product Firefox
    Version 3.6.11
    Build ID 20101012104758
    Branch 1.9.2
    OS Mac OS X
    OS Version 10.6.4 10F569
    CPU x86
    CPU Info GenuineIntel family 6 model 15 stepping 11
    Crash Reason EXC_BAD_ACCESS / KERN_PROTECTION_FAILURE
    Crash Address 0x8
    User Comments
    Processor Notes
    EMCheckCompatibility Fal

    Looking at the crash log it looks like AE might be crashing in:
    net.telestream.wmv.export 
    Can you try uinstalling Flip4Mac (or whatever you have installed from http://www.telestream.net/telestream-products/desktop-products.htm)? You may need to manually go deep into /System to remove them.
    --c

  • Java newbie help (type casting, 64bit unsigned Long)

    Hi I am java newbie and need help on my project. I have a few questions. Can you put strings in a hashtable and test for their being their with the appropriate hashtable method? I want to test for equal strings, not the same object. Second question can you use all 64 bits of an unsigned long? java doesn't seem to allow this. Any packages that do?
    Thanks,
    Dave

    Try casting it to Long instead of long. Long (capital L) is an Object, while long (lower case l) is not. You may also check to make sure the value isn't null. I would have thought that autoboxing would have worked here unless the value was null. But I am no expert on autoboxing.
    Edit >> Checking for null ain't a bad idea but has nothing to do with the problem - this is a compile time problem. Sorry.
    Also>> This code should work:
    long cTime=(Long)session.getAttribute("creationtime");Edited by: stevejluke on Jul 1, 2008 11:00 AM

  • Convert from String to Long

    Hello Frineds I want to convert from String to Long.
    My String is like str="600 700 250 300" and I want to convert it to long and
    get the total value in to the long variable.like the total of str in long varible should be 1850.
    Thank You
    Nilesh Vasani

    Maybe this would work?
    StringTokenizer st = new StringTokenizer(yourString, " ");
    long l = 0;
    while(st.hasMoreTokens()) {
        l += Long.parseLong(st.nextToken()).longValue();
    }

  • Urgent::Unsigned Long Requirement::Oracle Number(38) to Java conversion

    Hi,
    I have a Oracle field configured as NUMBER(38). The number in that field gets incremented sequentially and is currently around 5345232341.
    I am using callableStatement.registerOutParameter(1,java.sql.Types.INTEGER); which is working fine.
    But the problem happens when I am trying to retrieve the value and store it within my Program.
    I am using 'long' to do that but I presume I will hit a problem when the number crosses 9223372036854775807 (2^63-1). As we don't have unsigned long option in Java(unlike in C/C++), how do we achieve this? Please can somebpdy tell me the workaround.
    Currently, I am storing it as follows:
    long my_number = callableStatement.getInt(1);

    Currently, I am storing it as follows:
    long my_number = callableStatement.getInt(1);While reading the docs, you should probably also read about getInt(), because your current code is buggy.

  • How to specify in TS unsigned long? unsigned short?

    Hi,
    I'm lusing a c/c++ step type from TestStand.
    I need to use a structure whose fields according to the h file of the dll are:
    unsigned char
    unsigned long
    unsigned short
    Now, when I define a container in TestStand (to interface with the dll structure) my options are:
    integer
    unsigned integer
    etc...
    What am I supposed to do ?  what is the appropriate numeric format? 
    Thanks

    Hi Doug,
    I'm given the dll and load of h files.  The definitions you mentioned are not shown...
    Suppose I want to creat in TS a container to match variable FCPortConfig.  This variable structure is given here....
    typedef struct tagFCPortConfig
     unsigned char  ucTopology;    /* For Point-To-Point use TOPOLOGY_PT_2_PT
                  and for LOOP Topology use TOPOLOGY_LOOP */
     unsigned char  ucSpeed;     /* SPEED_1GHZ, SPEED_2GHZ       */
     unsigned char  ucDisableTimer;  /* (Not Currently Used) enable or disable
                  timeout timer          */
     unsigned long  ulRRDYGap;    /* (Not Currently Used) up to a 27-bit val */
     unsigned long  ulRRDYGapRandomEnable;/* (Not Currently Used)enable/disable   */
     unsigned long  ulRRDYGapSeed;   /* (Not Currently Used) If random set;
                  a 27-bit val          */
     unsigned long  ulRRDYGapMin;   /* (Not Currently Used) If random set;
                  a 27-bit val          */
     unsigned long  ulRRDYGapMax;   /* (Not Currently Used) If random set;
                  a 27-bit val          */
     unsigned char  ucAutoNegotiate;  /* (Not Currently Used) enable or disable
                  auto negotiation         */
     unsigned short uiBBCreditConfigRx; /* BB_credit this port will advertise   */
     unsigned char  ucStatsMode;   /* Determines weather or not to retrieve
                                              the extended stats counters, use
                                              STATS_MODE_NORMAL & STATS_MODE_EXTENDED */
     unsigned char  ucReserved[15];  /* Reserved */
    } FCPortConfig;
    1) Is there a way to find out how they define unsigned char, unsigned short and unsigned long?
    2) Can I still use the TS default numeric type?
    Thanks
    Rafi

  • Unsigned Long declaration in JAVA ?????

    Hi,
    Java doesnt allow unsigned declaration.
    I have a 'C' program which does the following:
    unsigned long someLongInteger; //in C
    someLong>>18;
    SomeLong<<14;
    SomeLong>>=14;
    When I did the same thing in JAVA by declaring someLongInteger as long, it gives me a different result.
    Is that because it is considering java Long as signed??
    Is there any work around this?
    I appreciate your reply
    Thank you.

    Depending on what you are trying to do, the unsigned right shift operator (>>>) may be of use for this situation.
    - K
    Hi,
    Java doesnt allow unsigned declaration.
    I have a 'C' program which does the following:
    unsigned long someLongInteger; //in C
    someLong>>18;
    SomeLong<<14;
    SomeLong>>=14;
    When I did the same thing in JAVA by declaring
    someLongInteger as long, it gives me a different
    result.
    Is that because it is considering java Long as
    signed??
    Is there any work around this?
    I appreciate your reply
    Thank you.

  • How to convert clob column to long

    Hi,
    Is there any way to convert clob column to long.
    Here below is my scenario..
    Instead of using substr function
    CREATE OR REPLACE PROCEDURE proc AS
    sql2 clob := '';
    sqlstring1 LONG;
    sqlstring2 LONG;
    sqlstring3 LONG;
    sqlstring4 LONG;
    sqlstring5 LONG;
    sqlstring6 LONG;
    sqlstring7 LONG;
    sqlstring8 LONG;
    sqlstring9 LONG;
    sqlstring10 LONG;
    BEGIN
    FOR sql1 IN (SELECT info FROM emp)
    LOOP
    sql2 := sql1.sql_string;
    sqlString1 := dbms_lob.SUBSTR(sql2, 8000, 1);
    sqlString2 := dbms_lob.SUBSTR(sql2, 8000, 8001);
    sqlString3 := dbms_lob.SUBSTR(sql2, 8000, 16001);
    sqlString4 := dbms_lob.SUBSTR(sql2, 8000, 24001);
    sqlString5 := dbms_lob.SUBSTR(sql2, 8000, 32001);
    sqlString6 := dbms_lob.SUBSTR(sql2, 8000, 40001);
    sqlString7 := dbms_lob.SUBSTR(sql2, 8000, 48001);
    sqlString8 := dbms_lob.SUBSTR(sql2, 8000, 56001);
    sqlString9 := dbms_lob.SUBSTR(sql2, 8000, 64001);
    sqlString10 := dbms_lob.SUBSTR(sql2, 8000, 72001);
    EXECUTE IMMEDIATE sqlString1 || sqlString2 || sqlString3 ||
    sqlString4 || sqlString5 || sqlString6 ||
    sqlString7 || sqlString8 || sqlstring9 ||
    sqlstring10;
    END LOOP;
    COMMIT;
    END proc;
    Any help really appreciated
    Thanks

    We cannot execute clob dynamically.That's what I said: execute immediate doesn't support CLOB!
    But you can concatenate two long's:
    SQL> DECLARE
       l_stmt1   LONG;
       l_stmt2   LONG;
    BEGIN
       l_stmt1 := RPAD ('BEGIN ', 32500, ' ');
       l_stmt2 :=
           RPAD ('  dbms_output.put_line(''Hello World'');', 32500, ' ')
           || 'END;';
       DBMS_OUTPUT.put_line ('Length of statement: '
                             || LENGTH (l_stmt1 || l_stmt2)
       EXECUTE IMMEDIATE (l_stmt1 || l_stmt2);
    END;
    Length of statement: 65004
    Hello World
    PL/SQL procedure successfully completed.So if you strip some extra spaces or try to compact your statement somehow, you might be able use above method.

  • EXTPROC DLL function "unsigned long" (DWORD) problem.

    Hi all!
    I'd like to pass a value to a function inside a DLL. The DLL parameter is a DWORD,
    I've specified the LIBRARY parameter as UB4 and the FUNCTION parameter is BINARY_INTEGER.
    This works pretty well until the value is larger than 2147483647 . This is (of course) beyond
    the limit of BINARY_INTEGER and PLS_INTEGER.
    BUT --- ext proc only can be mapped like this
    BINARY_INTEGER
    BOOLEAN
    PLS_INTEGER
    ------------>
    [UNSIGNED] CHAR
    [UNSIGNED] SHORT
    [UNSIGNED] INT
    [UNSIGNED] LONG
    SB1, SB2, SB4
    UB1, UB2, UB4
    SIZE_T
    So .. how can I pass a "real" unsinged integer to an external
    function, which allows a range up to 2^32-1 == 4294967295 ??
    Any hints? Thanks in advance!!
    No, I do not want to create a wrapper DLL :-)

    Hi!
    I am also in need of the solution to this, but could not get it right yet!
    Would you perhaps share your current solution (writing the wrapper) with me?....
    I will keep you posted if I find a way of using ora_ffi with a C Struct
    Bye!

Maybe you are looking for

  • Help please i need to set an animation cursor

    as abusy cursor. the problem is that i cant use setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); cous' the file is not the default wait_cursor of windows also i cant use: Image image = tkit.getImage( <filename/filepath>); Cursor customCurso

  • Launch of Adobe Captivate blocks on computer Windows 7 Professional

    Hello, I have installed Adobe Captivate 8.0 UK Win on a computer (Win7 professional version) at my work. The installation log file gives the following information : Exit Code: 6 Please see specific errors below for troubleshooting. For example,  ERRO

  • Problem with CRW files

    I just installed Aperture, changing from Photoshop Elements 4. But I have a problem with my .CRW files from my Canon Powershot S45 (RAW format). If I click on them, I get a glimps of a low resolution picture, but that is immediately replaced by the w

  • CS6 Indesign wont open, it just keeps crashing

    Hi, I've just downloaded CS6.  All the programmes other than Indesign are working. Every time I try and open Indesign, it just crashes. I've uninstalled 3 times, switched the machine off etc and still it wont open. Below is a screenshot of the error

  • FCP Export to Dropbox gives "cannot open in QT Player Document"

    What can I do to convert my FCP Export for it to be other than Quick Time Player Document format?  I tried Streamclip QT, Streamclip mpeg 4, same message from Dropbox: cannot open files in the QT Player format".  This is an emergency.  I'd appreciate