--
--	Inmos Libraries
--	Copyright (C) 1988, 1989, 1990, 1991, 1993  Inmos Limited
--
--	This library is free software; you can redistribute it and/or
--	modify it under the terms of the GNU Lesser General Public
--	License as published by the Free Software Foundation; either
--	version 2 of the License, or (at your option) any later version.
--
--	This library is distributed in the hope that it will be useful,
--	but WITHOUT ANY WARRANTY; without even the implied warranty of
--	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
--	Lesser General Public License for more details.
--
--	You should have received a copy of the GNU Lesser General Public
--	License along with this library; if not, write to the Free Software
--	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
--

--** @module maths

#OPTION "V"  -- no vector space
#COMMENT "Floating point maths library, V1.2 14/12/90"
#COMMENT "(c) Copyright INMOS Limited 1988"

--* Single-precision pseudo-random number generator.
--
-- @param SeedRan Input seed value
-- @return Pseudo-random value in the range [0.0, 1.0)
-- @return Output seed value
REAL32, INT32 FUNCTION RAN (VAL INT32 SeedRan)

  --{{{  history
  -- V1.0 1-Jul-88
  -- Added OPTION "V"; V1.1 27-Mar-90 SRH
  -- Removed the #INCLUDE "mathhdr.inc" by replacing `PLUS one' by
  -- `PLUS 1(INT32)', this makes the routine more independent; V1.2,
  -- 14-Dec-90 SRH
  --}}}

  VAL A IS 1664525(INT32) :
  INT32 NewSeed :
  VALOF
    NewSeed := (SeedRan TIMES A) PLUS 1(INT32) --create next integer in sequence
    RESULT SCALEB (REAL32 ROUND (NewSeed >> 1), -31), NewSeed
:
