简体   繁体   English

如何在不使用 Math.Pow 的 if 语句中将 10 提升为 9 (10^9)? C#

[英]How do I write 10 raised to 9 (10^9) in an if-statement not using Math.Pow? C#

I'm new to this so sorry if this question already have been answered.如果这个问题已经得到回答,我对此很抱歉。

I am writing a program in c# and I'm trying to make an if-statement where an integer cannot be higher than 10 raised to 9 (10^9) and not below or equivalent to 0. I tried to search for it and found that I perhaps can use the Math.Pow(10,9) but I don't see how I can do that in the if-statement?我正在 c# 中编写一个程序,我正在尝试制作一个 if 语句,其中 integer 不能高于 10 提高到 9 (10^9) 并且不低于或等于 0。我试图搜索它并发现我也许可以使用 Math.Pow(10,9) 但我不知道如何在 if 语句中做到这一点? Now I have only tried to compile the code while writing a big number, but it's supposed to be 10 raised to 9 and I don't know how to write it?现在我只尝试编译代码,同时写一个大数字,但它应该是10升到9,我不知道怎么写?

Here's the code:这是代码:

if (C > 100000 || C <= 0)

You can use the following code to validate if a number is between 10^9 and 0您可以使用以下代码验证数字是否介于 10^9 和 0 之间

  if (Math.Pow(10, 9) >= C &&  C > 0)
      Console.WriteLine("valid");
  else
      Console.WriteLine("Invalid");
       

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM