Merge branch 'master' of github.com:tgiphil/mono
[mono.git] / mcs / class / System.Data / System.Data.SqlTypes.jvm / SqlSingle.cs
1 // System.Data.SqlTypes.SqlSingle\r
2 //
3 // Authors:
4 //      Konstantin Triger <kostat@mainsoft.com>
5 //      Boris Kirzner <borisk@mainsoft.com>
6 //      
7 // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //\r
30 \r
31 namespace System.Data.SqlTypes\r
32 {\r
33 \r
34     /**\r
35      * <p>Title: </p>\r
36      * <p>Description: </p>\r
37      * <p>Copyright: Copyright (c) 2002</p>\r
38      * <p>Company: MainSoft</p>\r
39      * @author Pavel Sandler\r
40      * @version 1.0\r
41      */\r
42 \r
43     using System;\r
44 \r
45     public struct SqlSingle : INullable, IComparable\r
46     {\r
47 \r
48         private float _value;\r
49 \r
50         private static float _minVal = -3.40E+38F;\r
51         private static float _maxVal = 3.40E+38F;\r
52 \r
53         public static readonly SqlSingle MaxValue = new SqlSingle(3.40E+38F);\r
54         public static readonly SqlSingle MinValue = new SqlSingle(-3.40E+38F);\r
55         public static readonly SqlSingle Null = new SqlSingle(true);\r
56         public static readonly SqlSingle Zero = new SqlSingle(0);\r
57 \r
58         private bool _isNull;\r
59 \r
60         private SqlSingle(bool isNull)\r
61         {\r
62             _isNull = isNull;\r
63             _value = 0;\r
64         }\r
65 \r
66         /**\r
67          * Constructor\r
68          * @param value A float whose value will be used for the new SqlSingle.\r
69          */\r
70         public SqlSingle(float value) \r
71         { \r
72             _value = value;\r
73             _isNull = false;\r
74         }\r
75         \r
76 \r
77         /**\r
78          * Indicates whether or not Value is null.\r
79          * @return true if Value is null, otherwise false.\r
80          */\r
81         public bool IsNull\r
82         {\r
83             get\r
84             {\r
85                 return _isNull;\r
86             }\r
87         }\r
88 \r
89         /**\r
90          * Gets the value of the SqlSingle instance.\r
91          * @return the value of this instance\r
92          */\r
93         public float Value\r
94         {\r
95             get\r
96             {\r
97                 if(IsNull)\r
98                     throw new SqlNullValueException();\r
99                 return _value;\r
100             }\r
101         }\r
102 \r
103         /**\r
104          * The addition operator computes the sum of the two SqlSingle operands.\r
105          * @param x A SqlSingle structure.\r
106          * @param y A SqlSingle structure.\r
107          * @return The sum of the two SqlSingle operands.\r
108          * If one of the parameters is null or null value - return SqlSingle.Null.\r
109          */\r
110         public static SqlSingle Add(SqlSingle x, SqlSingle y)\r
111         {\r
112             if (x.IsNull || y.IsNull)\r
113                 return SqlSingle.Null;\r
114 \r
115             float xVal = x._value;\r
116             float yVal = y._value;\r
117 \r
118             if (xVal < 0 && yVal < 0 && (_minVal - xVal > yVal))\r
119                 throw new System.OverflowException("Overflow - " + x + " + " + y + " < " + _minVal);\r
120             if (xVal > 0 && yVal > 0 && (_maxVal - xVal < yVal))\r
121                 throw new System.OverflowException("Overflow - " + x + " + " + y + " > " + _maxVal);\r
122 \r
123 \r
124             return new SqlSingle(xVal + yVal);\r
125         }\r
126 \r
127         /**\r
128          * Compares this instance to the supplied object and returns an indication of their relative values.\r
129          * @param obj The object to compare.\r
130          * @return A signed number indicating the relative values of the instance and the object.\r
131          * Less than zero This instance is less than object.\r
132          * Zero This instance is the same as object.\r
133          * Greater than zero This instance is greater than object -or-\r
134          * object is a null reference.\r
135          */\r
136         public int CompareTo(Object obj)\r
137         {\r
138             if (obj == null)\r
139                 return 1;\r
140 \r
141             if (obj is SqlSingle)\r
142             {\r
143                 SqlSingle d = (SqlSingle)obj;\r
144 \r
145                 if (d.IsNull)\r
146                     return 1;\r
147                 if (this.IsNull)\r
148                     return -1;\r
149 \r
150                 return this._value.CompareTo(d._value);\r
151             }\r
152 \r
153             throw new ArgumentException("parameter obj is not SqlSingle : " + obj.GetType().Name);\r
154 \r
155         }\r
156 \r
157         /**\r
158          * The division operator divides the first SqlSingle operand by the second.\r
159          * @param x A SqlSingle instance.\r
160          * @param y A SqlSingle instance.\r
161          * @return A SqlSingle structure containing the results of the division operation.\r
162          * If one of the parameters is null or null value - return SqlSingle.Null.\r
163          */\r
164         public static SqlSingle Divide(SqlSingle x, SqlSingle y)\r
165         {\r
166             if (x.IsNull || y.IsNull)\r
167                 return SqlSingle.Null;\r
168 \r
169             float xVal = x._value;\r
170             float yVal = y._value;\r
171 \r
172             if (java.lang.Math.abs(yVal) < 1)\r
173             {\r
174                 if (xVal < 0 && yVal < 0 && (_maxVal * yVal > xVal))\r
175                     throw new System.OverflowException("Overflow - " + x + " / " + y + " > " + _maxVal);\r
176                 if (xVal < 0 && yVal > 0 && (_minVal * yVal > xVal))\r
177                     throw new System.OverflowException("Overflow - " + x + " / " + y + " < " + _minVal);\r
178                 if (xVal > 0 && yVal < 0 && (_minVal * yVal < xVal))\r
179                     throw new System.OverflowException("Overflow - " + x + " / " + y + " < " + _minVal);\r
180                 if (xVal > 0 && yVal > 0 && (_maxVal * yVal < xVal))\r
181                     throw new System.OverflowException("Overflow - " + x + " / " + y + " > " + _maxVal);\r
182             }\r
183 \r
184             return new SqlSingle(xVal / yVal);\r
185         }\r
186 \r
187         public override bool Equals(Object obj)\r
188         {\r
189             if (Object.ReferenceEquals(obj, this))\r
190                 return true;\r
191 \r
192             if (obj == null)\r
193                 return false;\r
194 \r
195             if (obj is SqlSingle)\r
196             {\r
197                 SqlSingle d = (SqlSingle)obj;\r
198 \r
199                 if (IsNull && d.IsNull)\r
200                     return true;\r
201 \r
202                 if (IsNull || d.IsNull)\r
203                     return false;\r
204 \r
205                 return _value.Equals(d._value);\r
206             }\r
207 \r
208             return false;\r
209         }\r
210 \r
211         \r
212 \r
213 \r
214         /**\r
215          * Performs a logical comparison on two instances of SqlSingle to determine if they are equal.\r
216          * @param x A SqlSingle instance.\r
217          * @param y A SqlSingle instance.\r
218          * @return true if the two values are equal, otherwise false.\r
219          * If one of the parameters is null or null value return SqlBoolean.Null.\r
220          */\r
221         public static SqlBoolean Equals(SqlSingle x, SqlSingle y)\r
222         {\r
223             if (x.IsNull || y.IsNull)\r
224                 return SqlBoolean.Null;\r
225 \r
226             if (x.Equals(y))\r
227                 return SqlBoolean.True;\r
228 \r
229             return SqlBoolean.False;\r
230         }\r
231 \r
232         /**\r
233          * Compares two instances of SqlSingle to determine if the first is greater than the second.\r
234          * @param x A SqlSingle instance\r
235          * @param y A SqlSingle instance\r
236          * @return A SqlBoolean that is True if the first instance is greater than the second instance, otherwise False.\r
237          * If either instance of SqlSingle is null, the Value of the SqlBoolean will be Null.\r
238          */\r
239         public static SqlBoolean GreaterThan(SqlSingle x, SqlSingle y)\r
240         {\r
241             if (x.IsNull || y.IsNull)\r
242                 return SqlBoolean.Null;\r
243 \r
244             if (x._value > y._value)\r
245                 return SqlBoolean.True;\r
246 \r
247             return SqlBoolean.False;\r
248         }\r
249 \r
250         /**\r
251          * Compares two instances of SqlSingle to determine if the first is greater than or equal to the second.\r
252          * @param x A SqlSingle instance\r
253          * @param y A SqlSingle instance\r
254          * @return A SqlBoolean that is True if the first instance is greaater than or equal to the second instance, otherwise False.\r
255          * If either instance of SqlSingle is null, the Value of the SqlBoolean will be Null.\r
256          */\r
257         public static SqlBoolean GreaterThanOrEqual(SqlSingle x, SqlSingle y)\r
258         {\r
259             if (x.IsNull || y.IsNull)\r
260                 return SqlBoolean.Null;\r
261 \r
262             if (x._value >= y._value)\r
263                 return SqlBoolean.True;\r
264 \r
265             return SqlBoolean.False;\r
266         }\r
267 \r
268         /**\r
269          * Compares two instances of SqlSingle to determine if the first is less than the second.\r
270          * @param x A SqlSingle instance\r
271          * @param y A SqlSingle instance\r
272          * @return A SqlBoolean that is True if the first instance is less than the second instance, otherwise False.\r
273          * If either instance of SqlSingle is null, the Value of the SqlBoolean will be Null.\r
274          */\r
275         public static SqlBoolean LessThan(SqlSingle x, SqlSingle y)\r
276         {\r
277             if (x.IsNull || y.IsNull)\r
278                 return SqlBoolean.Null;\r
279 \r
280             if (x._value < y._value)\r
281                 return SqlBoolean.True;\r
282 \r
283             return SqlBoolean.False;\r
284         }\r
285 \r
286         /**\r
287          * Compares two instances of SqlSingle to determine if the first is less than or equal to the second.\r
288          * @param x A SqlSingle instance\r
289          * @param y A SqlSingle instance\r
290          * @return A SqlBoolean that is True if the first instance is less than or equal to the second instance, otherwise False.\r
291          * If either instance of SqlSingle is null, the Value of the SqlBoolean will be Null.\r
292          */\r
293         public static SqlBoolean LessThanOrEqual(SqlSingle x, SqlSingle y)\r
294         {\r
295             if (x.IsNull || y.IsNull)\r
296                 return SqlBoolean.Null;\r
297 \r
298             if (x._value <= y._value)\r
299                 return SqlBoolean.True;\r
300 \r
301             return SqlBoolean.False;\r
302         }\r
303 \r
304         /**\r
305          * The multiplication operator computes the product of the two SqlSingle operands.\r
306          * @param x A SqlSingle instance\r
307          * @param y A SqlSingle instance\r
308          * @return The product of the two SqlSingle operands.\r
309          */\r
310         public static SqlSingle Multiply(SqlSingle x, SqlSingle y)\r
311         {\r
312             if (x.IsNull || y.IsNull)\r
313                 return SqlSingle.Null;\r
314 \r
315             float xVal = x._value;\r
316             float yVal = y._value;\r
317 \r
318             if (java.lang.Math.abs(xVal) > 1 && java.lang.Math.abs(yVal) > 1)\r
319             {\r
320                 if (xVal < 0 && yVal < 0 && (_maxVal / xVal > yVal))\r
321                     throw new System.OverflowException("Overflow - " + x + " * " + y + " > " + _maxVal);\r
322                 if (xVal < 0 && yVal > 0 && (_minVal / xVal < yVal))\r
323                     throw new System.OverflowException("Overflow - " + x + " * " + y + " < " + _minVal);\r
324                 if (xVal > 0 && yVal < 0 && (_minVal / xVal > yVal))\r
325                     throw new System.OverflowException("Overflow - " + x + " * " + y + " < " + _minVal);\r
326                 if (xVal > 0 && yVal > 0 && (_maxVal / xVal < yVal))\r
327                     throw new System.OverflowException("Overflow - " + x + " * " + y + " > " + _maxVal);\r
328             }\r
329 \r
330             return new SqlSingle(xVal * yVal);\r
331         }\r
332 \r
333 \r
334         /**\r
335          * Compares two instances of SqlSingle to determine if they are equal.\r
336          * @param x A SqlSingle instance\r
337          * @param y A SqlSingle instance\r
338          * @return A SqlBoolean that is True if the two instances are not equal or False if the two instances are equal.\r
339          * If either instance of SqlSingle is null, the Value of the SqlBoolean will be Null.\r
340          */\r
341         public static SqlBoolean NotEquals(SqlSingle x, SqlSingle y)\r
342         {\r
343             SqlBoolean res = Equals(x, y);\r
344 \r
345             if (res.IsNull)\r
346                 return res;\r
347             if (res.IsFalse)\r
348                 return SqlBoolean.True;\r
349 \r
350             return SqlBoolean.False;\r
351         }\r
352 \r
353         /**\r
354          * Converts the String representation of a number to its float-precision floating point number equivalent.\r
355          * @param s The String to be parsed.\r
356          * @return A SqlSingle containing the value represented by the String.\r
357          */\r
358         public static SqlSingle Parse(String s)\r
359         {\r
360             float d = Single.Parse(s);\r
361             return new SqlSingle(d);\r
362         }\r
363 \r
364         /**\r
365          * The subtraction operator the second SqlSingle operand from the first.\r
366          * @param x A SqlSingle instance\r
367          * @param y A SqlSingle instance\r
368          * @return The results of the subtraction operation.\r
369          */\r
370         public static SqlSingle Subtract(SqlSingle x, SqlSingle y)\r
371         {\r
372             if (x.IsNull || y.IsNull)\r
373                 return SqlSingle.Null;\r
374 \r
375             float xVal = x._value;\r
376             float yVal = y._value;\r
377 \r
378             if (xVal < 0 && yVal > 0 && (java.lang.Math.abs(_minVal - xVal) < yVal))\r
379                 throw new System.OverflowException("Overflow - " + x + " - " + y + " < " + _minVal);\r
380             if (xVal > 0 && yVal < 0 && (_maxVal - xVal < java.lang.Math.abs(yVal)))\r
381                 throw new System.OverflowException("Overflow - " + x + " - " + y + " > " + _maxVal);\r
382 \r
383 \r
384             return new SqlSingle(x._value - y._value);\r
385 \r
386         }\r
387 \r
388         /**\r
389          * Converts this SqlSingle structure to SqlBoolean.\r
390          * @return A SqlBoolean structure whose Value will be True if the SqlSingle structure's Value is non-zero, False if the SqlSingle is zero\r
391          * and Null if the SqlSingle structure is Null.\r
392          */\r
393         public SqlBoolean ToSqlBoolean()\r
394         {\r
395             if (_value == 0)\r
396                 return new SqlBoolean(0);\r
397 \r
398             return new SqlBoolean(1);\r
399         }\r
400 \r
401         /**\r
402          * Converts this SqlSingle structure to SqlByte.\r
403          * @return A SqlByte structure whose Value equals the Value of this SqlSingle structure.\r
404          */\r
405         public SqlByte ToSqlByte()\r
406         {\r
407             int val = (int)_value;\r
408 \r
409             if (val < 0 || val > 255)\r
410                 throw new OverflowException("Can not conver this instance to SqlByte - overflowing : " + val);\r
411 \r
412             return new SqlByte((byte)val);\r
413         }\r
414 \r
415         /**\r
416          * Converts this SqlSingle structure to SqlDouble.\r
417          * @return A SqlDouble structure whose Value equals the Value of this SqlSingle structure.\r
418          */\r
419         public SqlDouble ToSqlDouble()\r
420         {\r
421             return new SqlDouble(_value);\r
422         }\r
423 \r
424         /**\r
425          * Converts this SqlSingle structure to SqlDecimal.\r
426          * @return A SqlDecimal structure whose Value equals the Value of this SqlSingle structure.\r
427          */\r
428         public SqlDecimal ToSqlDecimal()\r
429         {\r
430             return new SqlDecimal(_value);\r
431         }\r
432 \r
433         /**\r
434          * Converts this SqlSingle structure to SqlInt16.\r
435          * @return A SqlInt16 structure whose Value equals the Value of this SqlSingle structure.\r
436          */\r
437         public SqlInt16 ToSqlInt16()\r
438         {\r
439             return new SqlInt16((short)_value);\r
440         }\r
441 \r
442         /**\r
443          * Converts this SqlSingle structure to SqlInt32.\r
444          * @return A SqlInt32 structure whose Value equals the Value of this SqlSingle structure.\r
445          */\r
446         public SqlInt32 ToSqlInt32()\r
447         {\r
448             return new SqlInt32((int)_value);\r
449         }\r
450 \r
451         /**\r
452          * Converts this SqlSingle structure to SqlInt64.\r
453          * @return A SqlInt64 structure whose Value equals the Value of this SqlSingle structure.\r
454          */\r
455         public SqlInt64 ToSqlInt64()\r
456         {\r
457             return new SqlInt64((long)_value);\r
458         }\r
459 \r
460         /**\r
461          * Converts this SqlSingle instance to SqlSingle.\r
462          * @return A SqlMoney instance whose Value equals the Value of this SqlSingle instance.\r
463          */\r
464         public SqlMoney ToSqlMoney()\r
465         {\r
466             return new SqlMoney(_value);\r
467         }\r
468 \r
469         /**\r
470          * Converts this SqlSingle structure to SqlString.\r
471          * @return A SqlString structure whose value is a string representing the date and time contained in this SqlSingle structure.\r
472          */\r
473         public SqlString ToSqlString()\r
474         {\r
475             return new SqlString(ToString());\r
476         }\r
477 \r
478 \r
479         public override String ToString()\r
480         {\r
481             if (IsNull)\r
482                 return "null";\r
483 \r
484             return _value.ToString();\r
485         }\r
486         \r
487         public override int GetHashCode()\r
488         {\r
489             return _value.GetHashCode();\r
490         }\r
491 \r
492         public static SqlSingle operator + (SqlSingle x, SqlSingle y)\r
493         {\r
494             float f = (float)(x.Value + y.Value);\r
495 \r
496             if (Single.IsInfinity (f))\r
497                 throw new OverflowException ();\r
498 \r
499             return new SqlSingle (f);\r
500         }\r
501 \r
502         public static SqlSingle operator / (SqlSingle x, SqlSingle y)\r
503         {\r
504             float f = (float)(x.Value / y.Value);\r
505 \r
506             if (Single.IsInfinity (f)) \r
507             {\r
508                                 \r
509                 if (y.Value == 0d) \r
510                     throw new DivideByZeroException ();\r
511             }\r
512 \r
513             return new SqlSingle (x.Value / y.Value);\r
514         }\r
515 \r
516         public static SqlBoolean operator == (SqlSingle x, SqlSingle y)\r
517         {\r
518             if (x.IsNull || y .IsNull) \r
519                 return SqlBoolean.Null;\r
520             return new SqlBoolean (x.Value == y.Value);\r
521         }\r
522 \r
523         public static SqlBoolean operator > (SqlSingle x, SqlSingle y)\r
524         {\r
525             if (x.IsNull || y .IsNull) \r
526                 return SqlBoolean.Null;\r
527             return new SqlBoolean (x.Value > y.Value);\r
528         }\r
529 \r
530         public static SqlBoolean operator >= (SqlSingle x, SqlSingle y)\r
531         {\r
532             if (x.IsNull || y .IsNull) \r
533                 return SqlBoolean.Null;\r
534             return new SqlBoolean (x.Value >= y.Value);\r
535         }\r
536 \r
537         public static SqlBoolean operator != (SqlSingle x, SqlSingle y)\r
538         {\r
539             if (x.IsNull || y .IsNull) \r
540                 return SqlBoolean.Null;\r
541             return new SqlBoolean (!(x.Value == y.Value));\r
542         }\r
543 \r
544         public static SqlBoolean operator < (SqlSingle x, SqlSingle y)\r
545         {\r
546             if (x.IsNull || y .IsNull) \r
547                 return SqlBoolean.Null;\r
548             return new SqlBoolean (x.Value < y.Value);\r
549         }\r
550 \r
551         public static SqlBoolean operator <= (SqlSingle x, SqlSingle y)\r
552         {\r
553             if (x.IsNull || y .IsNull) \r
554                 return SqlBoolean.Null;\r
555             return new SqlBoolean (x.Value <= y.Value);\r
556         }\r
557 \r
558         public static SqlSingle operator * (SqlSingle x, SqlSingle y)\r
559         {\r
560             float f = (float)(x.Value * y.Value);\r
561                         \r
562             if (Single.IsInfinity (f))\r
563                 throw new OverflowException ();\r
564 \r
565             return new SqlSingle (f);\r
566         }\r
567 \r
568         public static SqlSingle operator - (SqlSingle x, SqlSingle y)\r
569         {\r
570             float f = (float)(x.Value - y.Value);\r
571 \r
572             if (Single.IsInfinity (f))\r
573                 throw new OverflowException ();\r
574 \r
575             return new SqlSingle (f);\r
576         }\r
577 \r
578         public static SqlSingle operator - (SqlSingle n)\r
579         {\r
580             return new SqlSingle (-(n.Value));\r
581         }\r
582 \r
583         public static explicit operator SqlSingle (SqlBoolean x)\r
584         {\r
585             checked \r
586             {\r
587                 if (x.IsNull)\r
588                     return Null;\r
589                                 \r
590                 return new SqlSingle((float)x.ByteValue);\r
591             }\r
592         }\r
593 \r
594         public static explicit operator SqlSingle (SqlDouble x)\r
595         {\r
596             if (x.IsNull)\r
597                 return Null;\r
598 \r
599             float f = (float)x.Value;\r
600 \r
601             if (Single.IsInfinity (f))\r
602                 throw new OverflowException ();\r
603                                 \r
604             return new SqlSingle(f);\r
605         }\r
606 \r
607         public static explicit operator float (SqlSingle x)\r
608         {\r
609             return x.Value;\r
610         }\r
611 \r
612         public static explicit operator SqlSingle (SqlString x)\r
613         {\r
614             checked \r
615             {\r
616                 if (x.IsNull)\r
617                     return Null;\r
618                                 \r
619                 return SqlSingle.Parse (x.Value);\r
620             }\r
621         }\r
622 \r
623         public static implicit operator SqlSingle (float x)\r
624         {\r
625             return new SqlSingle (x);\r
626         }\r
627 \r
628         public static implicit operator SqlSingle (SqlByte x)\r
629         {\r
630             if (x.IsNull) \r
631                 return Null;\r
632             else \r
633                 return new SqlSingle((float)x.Value);\r
634         }\r
635 \r
636         public static implicit operator SqlSingle (SqlDecimal x)\r
637         {\r
638             if (x.IsNull) \r
639                 return Null;\r
640             else\r
641                 return new SqlSingle((float)x.Value);\r
642         }\r
643 \r
644         public static implicit operator SqlSingle (SqlInt16 x)\r
645         {\r
646             if (x.IsNull) \r
647                 return Null;\r
648             else\r
649                 return new SqlSingle((float)x.Value);\r
650         }\r
651 \r
652         public static implicit operator SqlSingle (SqlInt32 x)\r
653         {\r
654             if (x.IsNull) \r
655                 return Null;\r
656             else\r
657                 return new SqlSingle((float)x.Value);\r
658         }\r
659 \r
660         public static implicit operator SqlSingle (SqlInt64 x)\r
661         {\r
662             if (x.IsNull) \r
663                 return Null;\r
664             else\r
665                 return new SqlSingle((float)x.Value);\r
666         }\r
667 \r
668         public static implicit operator SqlSingle (SqlMoney x)\r
669         {\r
670             if (x.IsNull) \r
671                 return Null;\r
672             else\r
673                 return new SqlSingle((float)x.Value);\r
674         }\r
675 \r
676     }\r
677 }