Skip to content

Commit 803f70a

Browse files
committed
Changed Math to MathF
Tried to avoid reducing precision of calculations this time.
1 parent 5b040f6 commit 803f70a

26 files changed

+277
-208
lines changed

MonoGame.Framework/Audio/Xact/Cue.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public void Apply3D(AudioListener listener, AudioEmitter emitter)
255255
direction /= distance;
256256
var right = Vector3.Cross(listener.Up, listener.Forward);
257257
var slope = Vector3.Dot(direction, listener.Forward);
258-
var angle = MathHelper.ToDegrees((float)Math.Acos(slope));
258+
var angle = MathHelper.ToDegrees(MathF.Acos(slope));
259259
var j = FindVariable("OrientationAngle");
260260
_variables[j].SetValue(angle);
261261
if (_curSound != null)

MonoGame.Framework/BoundingSphere.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ public static BoundingSphere CreateFromPoints(IEnumerable<Vector3> points)
353353
float sqDist = diff.LengthSquared();
354354
if (sqDist > sqRadius)
355355
{
356-
float distance = (float)Math.Sqrt(sqDist); // equal to diff.Length();
356+
float distance = MathF.Sqrt(sqDist); // equal to diff.Length();
357357
Vector3 direction = diff / distance;
358358
Vector3 G = center - radius * direction;
359359
center = (G + pt) / 2;
@@ -581,7 +581,7 @@ public BoundingSphere Transform(Matrix matrix)
581581
{
582582
BoundingSphere sphere = new BoundingSphere();
583583
sphere.Center = Vector3.Transform(this.Center, matrix);
584-
sphere.Radius = this.Radius * ((float)Math.Sqrt((double)Math.Max(((matrix.M11 * matrix.M11) + (matrix.M12 * matrix.M12)) + (matrix.M13 * matrix.M13), Math.Max(((matrix.M21 * matrix.M21) + (matrix.M22 * matrix.M22)) + (matrix.M23 * matrix.M23), ((matrix.M31 * matrix.M31) + (matrix.M32 * matrix.M32)) + (matrix.M33 * matrix.M33)))));
584+
sphere.Radius = this.Radius * MathF.Sqrt(Math.Max(((matrix.M11 * matrix.M11) + (matrix.M12 * matrix.M12)) + (matrix.M13 * matrix.M13), Math.Max(((matrix.M21 * matrix.M21) + (matrix.M22 * matrix.M22)) + (matrix.M23 * matrix.M23), ((matrix.M31 * matrix.M31) + (matrix.M32 * matrix.M32)) + (matrix.M33 * matrix.M33))));
585585
return sphere;
586586
}
587587

@@ -593,7 +593,7 @@ public BoundingSphere Transform(Matrix matrix)
593593
public void Transform(ref Matrix matrix, out BoundingSphere result)
594594
{
595595
result.Center = Vector3.Transform(this.Center, matrix);
596-
result.Radius = this.Radius * ((float)Math.Sqrt((double)Math.Max(((matrix.M11 * matrix.M11) + (matrix.M12 * matrix.M12)) + (matrix.M13 * matrix.M13), Math.Max(((matrix.M21 * matrix.M21) + (matrix.M22 * matrix.M22)) + (matrix.M23 * matrix.M23), ((matrix.M31 * matrix.M31) + (matrix.M32 * matrix.M32)) + (matrix.M33 * matrix.M33)))));
596+
result.Radius = this.Radius * MathF.Sqrt(Math.Max(((matrix.M11 * matrix.M11) + (matrix.M12 * matrix.M12)) + (matrix.M13 * matrix.M13), Math.Max(((matrix.M21 * matrix.M21) + (matrix.M22 * matrix.M22)) + (matrix.M23 * matrix.M23), ((matrix.M31 * matrix.M31) + (matrix.M32 * matrix.M32)) + (matrix.M33 * matrix.M33))));
597597
}
598598

599599
#endregion

MonoGame.Framework/Graphics/PackedVector/Alpha8.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public override int GetHashCode()
120120

121121
private static byte Pack(float alpha)
122122
{
123-
return (byte) Math.Round(
123+
return (byte) MathF.Round(
124124
MathHelper.Clamp(alpha, 0, 1) * 255.0f
125125
);
126126
}

MonoGame.Framework/Graphics/PackedVector/Bgr565.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ public struct Bgr565 : IPackedVector<UInt16>, IEquatable<Bgr565>, IPackedVector
1515

1616
private static UInt16 Pack(float x, float y, float z)
1717
{
18-
return (UInt16) ((((int) Math.Round(MathHelper.Clamp(x, 0, 1) * 31.0f) & 0x1F) << 11) |
19-
(((int) Math.Round(MathHelper.Clamp(y, 0, 1) * 63.0f) & 0x3F) << 5) |
20-
((int) Math.Round(MathHelper.Clamp(z, 0, 1) * 31.0f) & 0x1F));
18+
return (UInt16) ((((int) MathF.Round(MathHelper.Clamp(x, 0, 1) * 31.0f) & 0x1F) << 11) |
19+
(((int) MathF.Round(MathHelper.Clamp(y, 0, 1) * 63.0f) & 0x3F) << 5) |
20+
((int) MathF.Round(MathHelper.Clamp(z, 0, 1) * 31.0f) & 0x1F));
2121
}
2222

2323
/// <summary>

MonoGame.Framework/Graphics/PackedVector/Bgra4444.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ public struct Bgra4444 : IPackedVector<UInt16>, IEquatable<Bgra4444>
1515

1616
private static UInt16 Pack(float x, float y, float z, float w)
1717
{
18-
return (UInt16) ((((int) Math.Round(MathHelper.Clamp(w, 0, 1) * 15.0f) & 0x0F) << 12) |
19-
(((int) Math.Round(MathHelper.Clamp(x, 0, 1) * 15.0f) & 0x0F) << 8) |
20-
(((int) Math.Round(MathHelper.Clamp(y, 0, 1) * 15.0f) & 0x0F) << 4) |
21-
((int) Math.Round(MathHelper.Clamp(z, 0, 1) * 15.0f) & 0x0F));
18+
return (UInt16) ((((int) MathF.Round(MathHelper.Clamp(w, 0, 1) * 15.0f) & 0x0F) << 12) |
19+
(((int) MathF.Round(MathHelper.Clamp(x, 0, 1) * 15.0f) & 0x0F) << 8) |
20+
(((int) MathF.Round(MathHelper.Clamp(y, 0, 1) * 15.0f) & 0x0F) << 4) |
21+
((int) MathF.Round(MathHelper.Clamp(z, 0, 1) * 15.0f) & 0x0F));
2222
}
2323

2424
/// <summary>

MonoGame.Framework/Graphics/PackedVector/Bgra5551.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ public override int GetHashCode()
127127
private static UInt16 Pack(float x, float y, float z, float w)
128128
{
129129
return (UInt16) (
130-
(((int) Math.Round(MathHelper.Clamp(x, 0, 1) * 31.0f) & 0x1F) << 10) |
131-
(((int) Math.Round(MathHelper.Clamp(y, 0, 1) * 31.0f) & 0x1F) << 5) |
132-
(((int) Math.Round(MathHelper.Clamp(z, 0, 1) * 31.0f) & 0x1F) << 0) |
133-
((((int) Math.Round(MathHelper.Clamp(w, 0, 1)) & 0x1) << 15))
130+
(((int) MathF.Round(MathHelper.Clamp(x, 0, 1) * 31.0f) & 0x1F) << 10) |
131+
(((int) MathF.Round(MathHelper.Clamp(y, 0, 1) * 31.0f) & 0x1F) << 5) |
132+
(((int) MathF.Round(MathHelper.Clamp(z, 0, 1) * 31.0f) & 0x1F) << 0) |
133+
((((int) MathF.Round(MathHelper.Clamp(w, 0, 1)) & 0x1) << 15))
134134
);
135135
}
136136
}

MonoGame.Framework/Graphics/PackedVector/Byte4.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ static uint Pack(ref Vector4 vector)
125125
const float min = 0.0f;
126126

127127
// clamp the value between min and max values
128-
var byte4 = (uint) Math.Round(MathHelper.Clamp(vector.X, min, max)) & 0xFF;
129-
var byte3 = ((uint) Math.Round(MathHelper.Clamp(vector.Y, min, max)) & 0xFF) << 0x8;
130-
var byte2 = ((uint) Math.Round(MathHelper.Clamp(vector.Z, min, max)) & 0xFF) << 0x10;
131-
var byte1 = ((uint) Math.Round(MathHelper.Clamp(vector.W, min, max)) & 0xFF) << 0x18;
128+
var byte4 = (uint) MathF.Round(MathHelper.Clamp(vector.X, min, max)) & 0xFF;
129+
var byte3 = ((uint) MathF.Round(MathHelper.Clamp(vector.Y, min, max)) & 0xFF) << 0x8;
130+
var byte2 = ((uint) MathF.Round(MathHelper.Clamp(vector.Z, min, max)) & 0xFF) << 0x10;
131+
var byte1 = ((uint) MathF.Round(MathHelper.Clamp(vector.W, min, max)) & 0xFF) << 0x18;
132132

133133
return byte4 | byte3 | byte2 | byte1;
134134
}

MonoGame.Framework/Graphics/PackedVector/NormalizedByte2.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ public override string ToString()
6767

6868
private static ushort Pack(float x, float y)
6969
{
70-
var byte2 = (((ushort) Math.Round(MathHelper.Clamp(x, -1.0f, 1.0f) * 127.0f)) & 0xFF) << 0;
71-
var byte1 = (((ushort) Math.Round(MathHelper.Clamp(y, -1.0f, 1.0f) * 127.0f)) & 0xFF) << 8;
70+
var byte2 = (((ushort) MathF.Round(MathHelper.Clamp(x, -1.0f, 1.0f) * 127.0f)) & 0xFF) << 0;
71+
var byte1 = (((ushort) MathF.Round(MathHelper.Clamp(y, -1.0f, 1.0f) * 127.0f)) & 0xFF) << 8;
7272

7373
return (ushort)(byte2 | byte1);
7474
}

MonoGame.Framework/Graphics/PackedVector/NormalizedByte4.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ public override string ToString()
6767

6868
private static uint Pack(float x, float y, float z, float w)
6969
{
70-
var byte4 = (((uint) Math.Round(MathHelper.Clamp(x, -1.0f, 1.0f) * 127.0f)) & 0xff) << 0;
71-
var byte3 = (((uint) Math.Round(MathHelper.Clamp(y, -1.0f, 1.0f) * 127.0f)) & 0xff) << 8;
72-
var byte2 = (((uint) Math.Round(MathHelper.Clamp(z, -1.0f, 1.0f) * 127.0f)) & 0xff) << 16;
73-
var byte1 = (((uint) Math.Round(MathHelper.Clamp(w, -1.0f, 1.0f) * 127.0f)) & 0xff) << 24;
70+
var byte4 = (((uint) MathF.Round(MathHelper.Clamp(x, -1.0f, 1.0f) * 127.0f)) & 0xff) << 0;
71+
var byte3 = (((uint) MathF.Round(MathHelper.Clamp(y, -1.0f, 1.0f) * 127.0f)) & 0xff) << 8;
72+
var byte2 = (((uint) MathF.Round(MathHelper.Clamp(z, -1.0f, 1.0f) * 127.0f)) & 0xff) << 16;
73+
var byte1 = (((uint) MathF.Round(MathHelper.Clamp(w, -1.0f, 1.0f) * 127.0f)) & 0xff) << 24;
7474

7575
return byte4 | byte3 | byte2 | byte1;
7676
}

MonoGame.Framework/Graphics/PackedVector/NormalizedShort2.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ private static uint PackInTwo (float vectorX, float vectorY)
8181

8282
// clamp the value between min and max values
8383
// Round rather than truncate.
84-
var word2 = (uint)((int)MathHelper.Clamp((float)Math.Round(vectorX * maxPos), minNeg, maxPos) & 0xFFFF);
85-
var word1 = (uint)(((int)MathHelper.Clamp((float)Math.Round(vectorY * maxPos), minNeg, maxPos) & 0xFFFF) << 0x10);
84+
var word2 = (uint)((int)MathHelper.Clamp(MathF.Round(vectorX * maxPos), minNeg, maxPos) & 0xFFFF);
85+
var word1 = (uint)(((int)MathHelper.Clamp(MathF.Round(vectorY * maxPos), minNeg, maxPos) & 0xFFFF) << 0x10);
8686

8787
return (word2 | word1);
8888
}

MonoGame.Framework/Graphics/PackedVector/NormalizedShort4.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ private static ulong PackInFour(float vectorX, float vectorY, float vectorZ, flo
7171
const long minNeg = -maxPos;
7272

7373
// clamp the value between min and max values
74-
var word4 = (ulong)((int)Math.Round(MathHelper.Clamp(vectorX * maxPos, minNeg, maxPos)) & mask);
75-
var word3 = (ulong)((int)Math.Round(MathHelper.Clamp(vectorY * maxPos, minNeg, maxPos)) & mask) << 0x10;
76-
var word2 = (ulong)((int)Math.Round(MathHelper.Clamp(vectorZ * maxPos, minNeg, maxPos)) & mask) << 0x20;
77-
var word1 = (ulong)((int)Math.Round(MathHelper.Clamp(vectorW * maxPos, minNeg, maxPos)) & mask) << 0x30;
74+
var word4 = (ulong)((int)MathF.Round(MathHelper.Clamp(vectorX * maxPos, minNeg, maxPos)) & mask);
75+
var word3 = (ulong)((int)MathF.Round(MathHelper.Clamp(vectorY * maxPos, minNeg, maxPos)) & mask) << 0x10;
76+
var word2 = (ulong)((int)MathF.Round(MathHelper.Clamp(vectorZ * maxPos, minNeg, maxPos)) & mask) << 0x20;
77+
var word1 = (ulong)((int)MathF.Round(MathHelper.Clamp(vectorW * maxPos, minNeg, maxPos)) & mask) << 0x30;
7878

7979
return (word4 | word3 | word2 | word1);
8080
}

MonoGame.Framework/Graphics/PackedVector/Rg32.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ public override int GetHashCode()
131131
private static uint Pack(float x, float y)
132132
{
133133
return (uint) (
134-
(((int) Math.Round(MathHelper.Clamp(x, 0, 1) * 65535.0f) & 0xFFFF) ) |
135-
(((int) Math.Round(MathHelper.Clamp(y, 0, 1) * 65535.0f) & 0xFFFF) << 16)
134+
(((int) MathF.Round(MathHelper.Clamp(x, 0, 1) * 65535.0f) & 0xFFFF) ) |
135+
(((int) MathF.Round(MathHelper.Clamp(y, 0, 1) * 65535.0f) & 0xFFFF) << 16)
136136
);
137137
}
138138
}

MonoGame.Framework/Graphics/PackedVector/Rgba1010102.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ public override int GetHashCode()
127127
private static uint Pack(float x, float y, float z, float w)
128128
{
129129
return (uint) (
130-
(((int) Math.Round(MathHelper.Clamp(x, 0, 1) * 1023.0f) & 0x03FF) << 0) |
131-
(((int) Math.Round(MathHelper.Clamp(y, 0, 1) * 1023.0f) & 0x03FF) << 10) |
132-
(((int) Math.Round(MathHelper.Clamp(z, 0, 1) * 1023.0f) & 0x03FF) << 20) |
133-
(((int) Math.Round(MathHelper.Clamp(w, 0, 1) * 3.0f) & 0x03) << 30)
130+
(((int) MathF.Round(MathHelper.Clamp(x, 0, 1) * 1023.0f) & 0x03FF) << 0) |
131+
(((int) MathF.Round(MathHelper.Clamp(y, 0, 1) * 1023.0f) & 0x03FF) << 10) |
132+
(((int) MathF.Round(MathHelper.Clamp(z, 0, 1) * 1023.0f) & 0x03FF) << 20) |
133+
(((int) MathF.Round(MathHelper.Clamp(w, 0, 1) * 3.0f) & 0x03) << 30)
134134
);
135135
}
136136
}

MonoGame.Framework/Graphics/PackedVector/Rgba64.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ public override int GetHashCode()
126126
private static ulong Pack(float x, float y, float z, float w)
127127
{
128128
return (ulong) (
129-
(((ulong)Math.Round(MathHelper.Clamp(x * 0xFFFF, 0, 65535f)) ) ) |
130-
(((ulong)Math.Round(MathHelper.Clamp(y * 0xFFFF, 0, 65535f)) ) << 16) |
131-
(((ulong)Math.Round(MathHelper.Clamp(z * 0xFFFF, 0, 65535f)) ) << 32) |
132-
(((ulong)Math.Round(MathHelper.Clamp(w * 0xFFFF, 0, 65535f)) ) << 48)
129+
(((ulong)MathF.Round(MathHelper.Clamp(x * 0xFFFF, 0, 65535f)) ) ) |
130+
(((ulong)MathF.Round(MathHelper.Clamp(y * 0xFFFF, 0, 65535f)) ) << 16) |
131+
(((ulong)MathF.Round(MathHelper.Clamp(z * 0xFFFF, 0, 65535f)) ) << 32) |
132+
(((ulong)MathF.Round(MathHelper.Clamp(w * 0xFFFF, 0, 65535f)) ) << 48)
133133
);
134134
}
135135
}

MonoGame.Framework/Graphics/PackedVector/Short2.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ private static uint PackInTwo (float vectorX, float vectorY)
8080
const float minNeg = ~(int)maxPos; // two's complement
8181

8282
// clamp the value between min and max values
83-
var word2 = ((uint) Math.Round(MathHelper.Clamp(vectorX, minNeg, maxPos)) & 0xFFFF);
84-
var word1 = (((uint) Math.Round(MathHelper.Clamp(vectorY, minNeg, maxPos)) & 0xFFFF) << 0x10);
83+
var word2 = ((uint) MathF.Round(MathHelper.Clamp(vectorX, minNeg, maxPos)) & 0xFFFF);
84+
var word1 = (((uint) MathF.Round(MathHelper.Clamp(vectorY, minNeg, maxPos)) & 0xFFFF) << 0x10);
8585

8686
return (word2 | word1);
8787
}

MonoGame.Framework/Graphics/PackedVector/Short4.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ static ulong Pack(ref Vector4 vector)
126126
const float minNeg = ~(int)maxPos; // two's complement
127127

128128
// clamp the value between min and max values
129-
var word4 = ((ulong)((int) Math.Round(MathHelper.Clamp(vector.X, minNeg, maxPos))) & mask);
130-
var word3 = ((ulong)((int) Math.Round(MathHelper.Clamp(vector.Y, minNeg, maxPos)) & mask)) << 0x10;
131-
var word2 = ((ulong)((int) Math.Round(MathHelper.Clamp(vector.Z, minNeg, maxPos)) & mask)) << 0x20;
132-
var word1 = ((ulong)((int) Math.Round(MathHelper.Clamp(vector.W, minNeg, maxPos)) & mask)) << 0x30;
129+
var word4 = ((ulong)((int) MathF.Round(MathHelper.Clamp(vector.X, minNeg, maxPos))) & mask);
130+
var word3 = ((ulong)((int) MathF.Round(MathHelper.Clamp(vector.Y, minNeg, maxPos)) & mask)) << 0x10;
131+
var word2 = ((ulong)((int) MathF.Round(MathHelper.Clamp(vector.Z, minNeg, maxPos)) & mask)) << 0x20;
132+
var word1 = ((ulong)((int) MathF.Round(MathHelper.Clamp(vector.W, minNeg, maxPos)) & mask)) << 0x30;
133133

134134
return word4 | word3 | word2 | word1;
135135
}

MonoGame.Framework/Graphics/SpriteBatch.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ public void Draw (Texture2D texture,
261261
-origin.Y,
262262
w,
263263
h,
264-
(float)Math.Sin(rotation),
265-
(float)Math.Cos(rotation),
264+
MathF.Sin(rotation),
265+
MathF.Cos(rotation),
266266
color,
267267
_texCoordTL,
268268
_texCoordBR,
@@ -398,8 +398,8 @@ public void Draw (Texture2D texture,
398398
-origin.Y,
399399
destinationRectangle.Width,
400400
destinationRectangle.Height,
401-
(float)Math.Sin(rotation),
402-
(float)Math.Cos(rotation),
401+
MathF.Sin(rotation),
402+
MathF.Cos(rotation),
403403
color,
404404
_texCoordTL,
405405
_texCoordBR,
@@ -734,8 +734,8 @@ public unsafe void DrawString (
734734
}
735735
else
736736
{
737-
cos = (float)Math.Cos(rotation);
738-
sin = (float)Math.Sin(rotation);
737+
cos = MathF.Cos(rotation);
738+
sin = MathF.Sin(rotation);
739739
transformation.M11 = (flippedHorz ? -scale.X : scale.X) * cos;
740740
transformation.M12 = (flippedHorz ? -scale.X : scale.X) * sin;
741741
transformation.M21 = (flippedVert ? -scale.Y : scale.Y) * (-sin);
@@ -1016,8 +1016,8 @@ public unsafe void DrawString (
10161016
}
10171017
else
10181018
{
1019-
cos = (float)Math.Cos(rotation);
1020-
sin = (float)Math.Sin(rotation);
1019+
cos = MathF.Cos(rotation);
1020+
sin = MathF.Sin(rotation);
10211021
transformation.M11 = (flippedHorz ? -scale.X : scale.X) * cos;
10221022
transformation.M12 = (flippedHorz ? -scale.X : scale.X) * sin;
10231023
transformation.M21 = (flippedVert ? -scale.Y : scale.Y) * (-sin);

MonoGame.Framework/MathF.cs

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// MonoGame - Copyright (C) The MonoGame Team
2+
// This file is subject to the terms and conditions defined in
3+
// file 'LICENSE.txt', which is part of this source code package.
4+
5+
namespace System
6+
{
7+
#if (!NETCOREAPP && !NETSTANDARD2_1) || NETCOREAPP1_0 || NETCOREAPP1_1
8+
internal static class MathF
9+
{
10+
public const float E = (float)Math.E;
11+
public const float PI = (float)Math.PI;
12+
13+
public static float Sqrt(float f)
14+
{
15+
return (float)Math.Sqrt(f);
16+
}
17+
18+
public static float Pow(float x, float y)
19+
{
20+
return (float)Math.Pow(x, y);
21+
}
22+
23+
public static float Sin(float f)
24+
{
25+
return (float)Math.Sin(f);
26+
}
27+
28+
public static float Cos(float f)
29+
{
30+
return (float)Math.Cos(f);
31+
}
32+
33+
public static float Tan(float f)
34+
{
35+
return (float)Math.Tan(f);
36+
}
37+
38+
public static float Asin(float f)
39+
{
40+
return (float)Math.Asin(f);
41+
}
42+
43+
public static float Acos(float f)
44+
{
45+
return (float)Math.Acos(f);
46+
}
47+
48+
public static float Atan(float f)
49+
{
50+
return (float)Math.Atan(f);
51+
}
52+
53+
public static float Round(float f)
54+
{
55+
return (float)Math.Round(f);
56+
}
57+
58+
public static float Ceiling(float f)
59+
{
60+
return (float)Math.Ceiling(f);
61+
}
62+
63+
public static float Floor(float f)
64+
{
65+
return (float)Math.Floor(f);
66+
}
67+
}
68+
#endif
69+
}

MonoGame.Framework/MathHelper.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static class MathHelper
1414
/// <summary>
1515
/// Represents the mathematical constant e(2.71828175).
1616
/// </summary>
17-
public const float E = (float)Math.E;
17+
public const float E = MathF.E;
1818

1919
/// <summary>
2020
/// Represents the log base ten of e(0.4342945).
@@ -29,7 +29,7 @@ public static class MathHelper
2929
/// <summary>
3030
/// Represents the value of pi(3.14159274).
3131
/// </summary>
32-
public const float Pi = (float)Math.PI;
32+
public const float Pi = MathF.PI;
3333

3434
/// <summary>
3535
/// Represents the value of pi divided by two(1.57079637).

0 commit comments

Comments
 (0)