--
--	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"

--* Double-precision pseudo-random number generator.
--
-- @param DSeedIn Input seed value
-- @return Pseudo-random value in the range [0.0, 1.0)
-- @return Output seed value
REAL64, INT64 FUNCTION DRAN (VAL INT64 DSeedIn)

  --{{{  history
  -- V1.0 1-Jul-88
  -- Added OPTION "V"; V1.1 27-Mar-90 SRH
  -- Replaced `PLUS one' by `PLUS 1(INT64)'; V1.2 14-Dec-90 SRH
  --}}}

  VAL A IS 6364136223846793005(INT64) :
  INT64 DSeedOut :
  VALOF
    DSeedOut := (DSeedIn TIMES A) PLUS 1(INT64) --creates next integer
    RESULT DSCALEB (REAL64 ROUND (DSeedOut >> 1), -63), DSeedOut
:
