calculation problem

M

Maor Mishkin

Hello All,
I have a calculation problem, the system changes it's accuracy during the
program,
attached is a sample with the bug, you can compile it and run it in debug
mode, then look at the changed result of ans1 & ans2.
So the question now is how do I change the accuracy?
Thanks Maor.






using System;

using System.Drawing;

using System.Windows.Forms;

using Microsoft.DirectX;

using Microsoft.DirectX.Direct3D;

using Direct3D=Microsoft.DirectX.Direct3D;

namespace test

{

public class test

{

/// <summary>

/// The main entry point for the application.

/// </summary>

static void Main()

{



PresentParameters presentParams = new PresentParameters();

presentParams.Windowed=true; // We don't want to run fullscreen

presentParams.SwapEffect = SwapEffect.Discard; // Discard the frames

presentParams.EnableAutoDepthStencil = true; // Turn on a Depth stencil

presentParams.AutoDepthStencilFormat = DepthFormat.D16; // And the stencil
format

double a = 10.0;

double b = 220.0;

double ans1 = a/b;

Device device = new Device(0, DeviceType.Hardware, new Panel(),
CreateFlags.SoftwareVertexProcessing, presentParams); //Create a device


double ans2 = a/b;

decimal a4 = 10;

decimal b4 = 220;

decimal ans4 = a4/b4;

double ans5 = (double)ans1;

float ans6 = (float)ans1;

//ans6++;

//ans6--;

double ans7 = (double)ans6;

double ans9 = (double)ans4;

double ans8 = decimal.ToDouble(ans4);

decimal.

decimal ans3 = decimal.Divide((decimal)a,(decimal)b);

int r =2; //for break point



}

}

}
 
A

Andy Mortimer [MS]

You may want to describe what the actual problem is (so that people dont
have to install SDK's and build the software to understand what you are
getting at.)

Andy Mortimer [MS]
Please do not send email directly to this alias. This alias is for
newsgroup purposes only

This posting is provided "AS IS" with no warranties, and confers no rights.
OR if you wish to include a script sample in your post please add "Use of
included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm"
 
Top