For Programmers: Free Programming Magazines  


Home > Archive > Fortran > November 2004 > How to specify signed/unsigned value in F90









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to specify signed/unsigned value in F90
denis

2004-11-25, 3:57 pm

Hi all,

I have an array of integer*2 values. How could I say to F90 that values
range from 0 to 65535 (and not from -32767 to 32767).

Thanks

Denis
meek@skyway.usask.ca

2004-11-25, 3:57 pm

In a previous article, denis <dpithon@freenospam.fr> wrote:
>Hi all,
>
>I have an array of integer*2 values. How could I say to F90 that values
>range from 0 to 65535 (and not from -32767 to 32767).
>
>Thanks
>
>Denis


simple way --

Integer*4 I4
integer*2 i2
...
i4=i2
if(i4.lt.0)i4=i4+32768

... but I sure there's a compicated way out there just
waiting to pounce!

Chris
David T. Croft, Ph.D.

2004-11-26, 4:02 am

There is no pre-defined unsigned integer. If it is important one can be
defined using F90. The value can be stored as an integer and operators can
be "overloaded".

David.T.Croft@AdsorptionProcessModeling.com

"denis" <dpithon@freenospam.fr> wrote in message
news:41a614bf$0$30293$626a14ce@news.free.fr...
> Hi all,
>
> I have an array of integer*2 values. How could I say to F90 that values
> range from 0 to 65535 (and not from -32767 to 32767).
>
> Thanks
>
> Denis



Robert Corbett

2004-11-30, 3:58 am

denis <dpithon@freenospam.fr> wrote in message news:<41a614bf$0$30293$626a14ce@news.free.fr>...
> Hi all,
>
> I have an array of integer*2 values. How could I say to F90 that values
> range from 0 to 65535 (and not from -32767 to 32767).
>
> Thanks
>
> Denis


In standard Fortran, you can't. If you are using Sun f90/f95,
you could use the intrinsic function TRANSFER, where the second
argument is an UNSIGNED*2 variable. If the array is static, you
could EQUIVALENCE it to an UNSIGNED*2 array.

Sincerely,
Bob Corbett
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com