2004-03-10 Joerg Rosenkranz <JoergR@voelcker.com>
[mono.git] / mcs / class / Microsoft.VisualBasic / Microsoft.VisualBasic / VBMath.cs
1 //
2 // VBMath.cs
3 //
4 // Author:
5 //   Chris J Breisch (cjbreisch@altavista.net) 
6 //   Francesco Delfino (pluto@tipic.com)
7 //
8 // (C) 2002 Chris J Breisch
9 // (C) 2002 Tipic Inc
10 //
11
12 using System;
13
14 namespace Microsoft.VisualBasic {
15         [Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute] 
16         sealed public class VBMath {
17                 // Declarations
18                 // Constructors
19                 // Properties
20                 static Random rnd = new Random();
21                 static float last = (float)rnd.NextDouble();
22                 // Methods
23                 public static float Rnd () {
24                         last =  (float)rnd.NextDouble();
25                         return last; 
26                 }
27                 public static float Rnd (float Number) 
28                 {\r
29                         if (Number == 0.0)
30                         {
31                                 return last;
32                         } \r
33                         else if (Number < 0.0 )\r
34                         {
35                                 //fd: What does this mean?
36                                 //fd: ms-help://MS.VSCC/MS.MSDNVS/script56/html/vsstmRandomize
37                                 //fd: ms-help://MS.VSCC/MS.MSDNVS/script56/html/vsfctrnd.htm
38                                 Randomize(Number);
39                                 return Rnd();
40                         }
41                         return Rnd();
42                 } 
43                 public static void Randomize () { 
44                         rnd = new Random();
45                 } 
46                 [MonoTODO("Rethink the double => int conversion")]
47                 public static void Randomize (double Number) 
48                 { 
49                         rnd = new Random((int)Number);
50                 }
51                 // Events
52         };
53 }