VB.NET代码:
Module Module1
Sub Main()
Dim x, y As Single
x = 0 + (512 / 2 - 407) / 256 * 192 * -1
y = 0 + (512 / 2 - 474) / 256 * 192
Console.WriteLine(x.ToString + ": " + y.ToString)
Console.ReadLine()
End Sub
End Module
Run Code Online (Sandbox Code Playgroud)
返回:113,25:-163,5
C#代码:
class Program
{
static void Main(string[] args)
{
float x, y;
x = 0 + (512 / 2 - 407) / 256 * 192 * -1;
y = 0 …Run Code Online (Sandbox Code Playgroud) 此行发生错误:
xPoint是Int32
randomsize是int
xPoint = pictureBox1.Width / 2 - randomsize - objectPos.getOffset / 10 * randomsize / 192;
Run Code Online (Sandbox Code Playgroud)
这是显然导致它的功能,有人能解释我为什么吗?
public float getSector()
{
return (float)Math.Floor(x / 192 + 135);
}
public Int32 getOffset ()
{
return (Int32)((x / 192) - getSector() + 135) * 192 * 10;
}
Run Code Online (Sandbox Code Playgroud)