分割问题 [英] Divide problem

查看:89
本文介绍了分割问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我感到非常惊讶,当我发现我的代码没有工作,所以我创建了一个控制台应用程序,看看问题出在哪里,当我看到下面的返回代码,我已经得到了更惊讶0

I was very surprised when I found out my code wasn't working so I created a console application to see where the problem lies and I've got even more surprised when I saw the code below returns 0

    static void Main(string[] args)
    {
        float test = 140 / 1058;
        Console.WriteLine(test);
        Console.ReadLine();
    }



我试图得到结果以%并把它放在一个进度(意思是(一千零五十八分之一百四十〇)* 100)栏上我的应用程序,第二个值(1058)是在我的应用程序实际上ULONG类型,但是这似乎并不成为问题。

I'm trying to get the result in % and put it in a progress(meaning (140 / 1058) * 100) bar on my application,the second value(1058) is actually ulong type in my application,but that doesn't seem to be the problem.

现在的问题是 - 问题出在哪里。

The question is - where the problem is?

推荐答案

这会工作,你希望的方式... <? / p>

This will work the way you expect ...

float test = (float)140 / (float)1058;



顺便说一句,你的代码工作正常,我(打印0.1323251到控制台)。

By the way, your code works fine for me (prints a 0.1323251 to the console).

这篇关于分割问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆