Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.basic.powerbasic > #60 > unrolled thread

Conversion.

Started by"Unknown" <un.known@unknown.tt>
First post2012-11-27 16:34 +0100
Last post2012-11-27 20:37 +0000
Articles 3 — 3 participants

Back to article view | Back to comp.lang.basic.powerbasic


Contents

  Conversion. "Unknown" <un.known@unknown.tt> - 2012-11-27 16:34 +0100
    Re: Conversion. "Auric__" <not.my.real@email.address> - 2012-11-27 19:40 +0000
      Re: Conversion. Wildman <best_lay@yahoo.com> - 2012-11-27 20:37 +0000

#60 — Conversion.

From"Unknown" <un.known@unknown.tt>
Date2012-11-27 16:34 +0100
SubjectConversion.
Message-ID<RPCdnSZTCdk2QCnNnZ2dnUVZ8k-dnZ2d@lyse.net>
Hello!

How can a signed 64 bits QUAD integer in PB be converted to a unsigned 64 
bit integer?
Thanks!
--

[toc] | [next] | [standalone]


#61

From"Auric__" <not.my.real@email.address>
Date2012-11-27 19:40 +0000
Message-ID<XnsA11880EA754D5auricauricauricauric@88.198.244.100>
In reply to#60
Unknown wrote:

> How can a signed 64 bits QUAD integer in PB be converted to a unsigned 64
> bit integer?

PowerBASIC doesn't have an unsigned 64-bit data type. You can fake it using 
EXT variables:

  f80## = CEXT(i64&&)

...but note that due to how QUADs are implemented, and the limitations of 
floating-point types, very large values lose precision. (Read the help file's 
QUAD and EXT entries.) If that's not acceptable, you'll need to roll your own 
data type. Google for something like "implement unsigned 64-bit integer 
basic".

If you absolutely *must* have an unsigned 64-bit integer, and don't want to 
roll your own, you'll need to use a different language. (For example, 
FreeBASIC has ULONGINT, and QB64 (apparently) has _UNSIGNED _INTEGER64.)

-- 
It takes 24 hours to recover from a fake illness.

[toc] | [prev] | [next] | [standalone]


#62

FromWildman <best_lay@yahoo.com>
Date2012-11-27 20:37 +0000
Message-ID<Fw9ts.36337$kP4.16041@newsfe15.iad>
In reply to#61
On Tue, 27 Nov 2012 19:40:39 +0000, Auric__ wrote:

> Unknown wrote:
> 
>> How can a signed 64 bits QUAD integer in PB be converted to a unsigned
>> 64 bit integer?
> 
> PowerBASIC doesn't have an unsigned 64-bit data type. You can fake it
> using EXT variables:
> 
>   f80## = CEXT(i64&&)
> 
> ...but note that due to how QUADs are implemented, and the limitations
> of floating-point types, very large values lose precision. (Read the
> help file's QUAD and EXT entries.) If that's not acceptable, you'll need
> to roll your own data type. Google for something like "implement
> unsigned 64-bit integer basic".
> 
> If you absolutely *must* have an unsigned 64-bit integer, and don't want
> to roll your own, you'll need to use a different language. (For example,
> FreeBASIC has ULONGINT, and QB64 (apparently) has _UNSIGNED _INTEGER64.)

There is a discussion on using the PB EXT data type for unsigned
64-bit numbers with some code examples here:
http://www.powerbasic.com/support/pbforums/showthread.php?t=51350
And here:
http://www.powerbasic.com/support/pbforums/showthread.php?p=387026

Just so happens that I had been researching the EXT data type for
the same purpose so I had the links bookmarked already.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.basic.powerbasic


csiph-web