I am converting a C program to NetRexx and the lack of unsigned integer types really pinches. I see that Java 8 has support for unsigned types:
Are we able to make use of this? -- "I don’t believe in the afterlife, although I am bringing a change of underwear." - W. Allen
_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Hi, George - Can you specify exactly what the problem is that you have encountered? The page you linked to is confused as is typical of Oracle docs but apparently it means that in Java 8 you can wrap primitive integers with Integer or Long objects and then use some new methods that treat the values as unsigned. That should work in NetRexx without any problem. However some Java operators treat primitive integers independently of sign values (sign does not affect results). To obtain that behavior in NetRexx a binary method may be required. Otherwise NetRexx likely auto converts to Rexx values and uses decimal operations with possibly different results. Without knowing exactly what you are doing it would be difficult to devise suitable test cases to clarify the behavior. -- Kermit On 2/11/2015 11:18 AM, George Hovey
wrote:
_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
In reply to this post by George Hovey-2
Hi George,
maybe I'm too stupid ... Wherefrom in the referenced documentation do You derive that <+unsigned integers+> are supported nowadays by the Java language? The only solution I do see is to convert the unsigned integers to Decimal Strings :-( Thomas. =========================================================================================== Am 11/02/2015 um 20:18 schrieb George
Hovey:
_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
Thomas Schneider, Vienna, Austria (Europe) :-)
www.thsitc.com www.db-123.com |
To be more exact in my second (and last) response:
- convert <+unsigned int's+> TO <+long+> (and remember the change of the size ;-)) - convert <+unsigned long's+> TO <+Decimal Strings+> Just a proposal, of course ... Thomas. PS: Who of You has ever seen the datatype <+unsigned long+> actually used? Me *not* ;-) ;-) ;-) ============================================================================ Am 12/02/2015 um 18:44 schrieb Thomas
Schneider:
Hi George, _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
Thomas Schneider, Vienna, Austria (Europe) :-)
www.thsitc.com www.db-123.com |
@Kermit, @Thomas Sorry, got sidetracked and this slipped my mind. 1. i = 0xFFFFFFFF 2. i = "FFFFFFFF".toint( ) 3. i = "0xFFFFFFFF".toint( ) The first produced the compiler error: "Cannot convert value of type 'long' for assignment to variable of type 'int'" [Kind of interesting message; would like to see an explanation for it.] The second and third produced the run-time error: "java.lang.NumberFormatException: FFFFFFFF" "PS: Who of You has ever seen the datatype <+unsigned long+> actually used? Me *not* " Maybe it's not used in the IBM world; you should get around more. :) On Thu, Feb 12, 2015 at 1:06 PM, Thomas Schneider <[hidden email]> wrote:
-- "I don’t believe in the afterlife, although I am bringing a change of underwear." - W. Allen
_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Maybe working with BitSets or ByteArrays? http://docs.oracle.com/javase/7/docs/api/java/util/BitSet.html http://docs.oracle.com/javase/7/docs/api/java/lang/Byte.html http://stackoverflow.com/questions/19791255/how-to-convert-byte-array-to-long-without-using-java-nio On Wed, Apr 1, 2015 at 3:39 PM, George Hovey <[hidden email]> wrote:
_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
In reply to this post by George Hovey-2
Hi George, some comments below.
_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
8xFFFFFFFF only 17 results doing a Google search. New to me.On Thu, Apr 2, 2015 at 3:02 AM, Mike Cowlishaw <[hidden email]> wrote:
_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
In reply to this post by George Hovey-2
Actually, the first message is perfectly logical, since hex values are not considered signed (I.e. Carry no sign). So, your 0xFFFFFFFF can only be represented in a long as a positive integer.
--
Robert P. Nix | Sr IT Systems Engineer | Data Center Infrastructure Services507-284-0844 | <a href="applewebdata://7C28AA03-E9D7-4519-A679-80B7EC6A010B/Nix.Robert@mayo.edu" style="color: purple; font-family: Calibri, Verdana, Helvetica, Arial; font-size: 15px;">Nix.Robert@... Mayo Clinic| 200 First Street SW | Rochester, MN 55905 Mayo Clinic, a mission-driven worldwide leader in health care for 150 years. http://150years.mayoclinic.org/
From: George Hovey <[hidden email]>
Reply-To: IBM Netrexx <[hidden email]> Date: Wednesday, April 1, 2015 at 2:39 PM To: IBM Netrexx <[hidden email]> Subject: Re: [Ibm-netrexx] Unsigned integer types
_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Robert Nix's explanation sounds right to me. That's the workaround I've been using - define such ints as longs and cast them back to ints when these are needed. What about shifts? It's a puzzle to me that NetRexx omits them. My workaround is to embed the int in the lower 32 bits of a long; multiply or divide it by a power of two contained in a look-up table; and cast the result to an int. It's certainly unlovely. Is there a better way?On Mon, Apr 6, 2015 at 2:02 PM, Nix, Robert P. <[hidden email]> wrote:
-- "I don’t believe in the afterlife, although I am bringing a change of underwear." - W. Allen
_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Hi George, sounds as though my post didn't get through;
there's no need for a 'workaround'. Here it is again:
Hi George, some comments below.
_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Free forum by Nabble | Edit this page |