comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: random integers between 0 and 1,000,000
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: random integers between 0 and 1,000,000 [message #45956 is a reply to message #45955] Mon, 24 October 2005 09:36 Go to previous messageGo to previous message
Norbert Hahn is currently offline  Norbert Hahn
Messages: 46
Registered: May 2003
Member
"James Kuyper" <kuyper@wizard.net> wrote:

> takes a 32 bit unsigned long with a value somewhere in the range from 0
> to 1000000, and converts it into a 16 bit signed int, with a range from
> -32768 to 32767.

I took a closer look on what might have gone on. I ran the following
program:

z = randomu(seed,30)
a = long (z*1000000) & print, a
b = ulong (z*1000000) & print, b
i = fix(a)
print, a

I found that a(1) was negative (-20848). So I printed

print, a[1], format="(z8)"
print, b[1], format="(z8)"
print, i[1], format="(z4)"

and got 4AE90 for both a[1] and b[1] and I got AE90 for i[1]

Thus the fix function simply takes the 16 low order bits from either long
or ulong variable and stores it into the result.

Norbert
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Problem: Opening a 20-30MB sized ShapeFile
Next Topic: Keeping Button Pressed In?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 22:02:30 PDT 2025

Total time taken to generate the page: 0.15813 seconds