🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #519

Re: Converting int to unsigned int

#519
From: Alexey N. Solofnenko
Date: Wed, 15 Jun 2005 14:06
26 lines
1674 bytes
I would suggest: (value>=0 ? value : 65536+value). 32767 should not be 
changed - it is already a positive integer, but -1 is actually 65535.

- Alexey.

Rick wrote:
> Hi,
> 
> Probably a simple question: how to convert a signed int to an unsigned int?
> 
> My applets gets a string value holding a 16-bits integer value. Before I 
> want to display it, this value needs to be converted to an unsigned int(16 
> bits) and then back in a string. So the input string "32767" becomes 
> "65535".
> I thought the conversion would be this,
>     uint16    = int16 * 2 +1
> but I'm not sure though
> 
> Greetings,
> Rick 
> 
> 

-- 
Alexey N. Solofnenko
home: http://trelony.cjb.net/
Technical Details
Message-ID: <42b035f6@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <42b02669@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,7f36f11f2652901
X-Google-Attributes: gidf74b3,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Wed, 15 Jun 2005 07:06:47 -0700
From: "Alexey N. Solofnenko" <nospam@nospam.comp>
User-Agent: Mozilla Thunderbird 1.0+ (X11/20050610)
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language
Subject: Re: Converting int to unsigned int
References: <42b02669@newsgroups.borland.com>
In-Reply-To: <42b02669@newsgroups.borland.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 67.188.247.45
Message-ID: <42b035f6@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1118844406 67.188.247.45 (15 Jun 2005 07:06:46 -0700)
Lines: 26
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail