• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

VB.NET Math.Abs方法代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了VB.NET中System.Math.Abs方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Math.Abs方法的具体用法?VB.NET Math.Abs怎么用?VB.NET Math.Abs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Math的用法示例。



在下文中一共展示了Math.Abs方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。

示例1: Example

Module Example
   Public Sub Main()
      Dim decimals() As Decimal = { Decimal.MaxValue, 12.45D, 0D, -19.69D, _
                                    Decimal.MinValue }
      For Each value As Decimal In decimals
         Console.WriteLine("Abs({0}) = {1}", value, Math.Abs(value))
      Next
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System,代码行数:9,代码来源:Math.Abs

输出:

Abs(79228162514264337593543950335) = 79228162514264337593543950335
Abs(12.45) = 12.45
Abs(0) = 0
Abs(-19.69) = 19.69
Abs(-79228162514264337593543950335) = 79228162514264337593543950335


示例2: Example

Module Example
   Public Sub Main()
      Dim doubles() As Double = { Double.MaxValue, 16.354e-17, 15.098123, 0, _
                                  -19.069713, -15.058e18, Double.MinValue }
      For Each value As Double In doubles
         Console.WriteLine("Abs({0}) = {1}", value, Math.Abs(value))
      Next
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System,代码行数:9,代码来源:Math.Abs

输出:

Abs(1.79769313486232E+308) = 1.79769313486232E+308
Abs(1.6354E-16) = 1.6354E-16
Abs(15.098123) = 15.098123
Abs(0) = 0
Abs(-19.069713) = 19.069713
Abs(-1.5058E+19) = 1.5058E+19
Abs(-1.79769313486232E+308) = 1.79769313486232E+308


示例3: Example

Module Example
   Public Sub Main()
      Dim values() As Short = { Int16.MaxValue, 10328, 0, -1476, Int16.MinValue }
      For Each value As Short In values
         Try
            Console.WriteLine("Abs({0}) = {1}", value, Math.Abs(value))
         Catch e As OverflowException
            Console.WriteLine("Unable to calculate the absolute value of {0}.", _
                              value)
         End Try   
      Next
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System,代码行数:13,代码来源:Math.Abs

输出:

Abs(32767) = 32767
Abs(10328) = 10328
Abs(0) = 0
Abs(-1476) = 1476
Unable to calculate the absolute value of -32768.


示例4: Example

Module Example
   Public Sub Main()
      Dim values() As Integer = { Int32.MaxValue, 16921, 0, -804128, Int32.MinValue }
      For Each value As Integer In values
         Try
            Console.WriteLine("Abs({0}) = {1}", value, Math.Abs(value))
         Catch e As OverflowException
            Console.WriteLine("Unable to calculate the absolute value of {0}.", _
                              value)
         End Try   
      Next
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System,代码行数:13,代码来源:Math.Abs

输出:

Abs(2147483647) = 2147483647
Abs(16921) = 16921
Abs(0) = 0
Abs(-804128) = 804128
Unable to calculate the absolute value of -2147483648.


示例5: Example

Module Example
   Public Sub Main()
      Dim values() As Long = { Int64.MaxValue, 109013, 0, -6871982, Int64.MinValue }
      For Each value As Long In values
         Try
            Console.WriteLine("Abs({0}) = {1}", value, Math.Abs(value))
         Catch e As OverflowException
            Console.WriteLine("Unable to calculate the absolute value of {0}.", _
                              value)
         End Try   
      Next
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System,代码行数:13,代码来源:Math.Abs

输出:

Abs(9223372036854775807) = 9223372036854775807
Abs(109013) = 109013
Abs(0) = 0
Abs(-6871982) = 6871982
Unable to calculate the absolute value of -9223372036854775808.


示例6: Example

Module Example
   Public Sub Main()
      Dim values() As SByte = { SByte.MaxValue, 98, 0, -32, SByte.MinValue }
      For Each value As SByte In values
         Try
            Console.WriteLine("Abs({0}) = {1}", value, Math.Abs(value))
         Catch e As OverflowException
            Console.WriteLine("Unable to calculate the absolute value of {0}.", _
                              value)
         End Try   
      Next
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System,代码行数:13,代码来源:Math.Abs

输出:

Abs(127) = 127
Abs(98) = 98
Abs(0) = 0
Abs(-32) = 32
Unable to calculate the absolute value of -128.


示例7: Example

Module Example
   Public Sub Main()
      Dim values() As Single = { Single.MaxValue, 16.354e-12, 15.098123, 0, _
                                  -19.069713, -15.058e17, Single.MinValue }
      For Each value As Single In values
         Console.WriteLine("Abs({0}) = {1}", value, Math.Abs(value))
      Next
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System,代码行数:9,代码来源:Math.Abs

输出:

Abs(3.402823E+38) = 3.402823E+38
Abs(1.6354E-11) = 1.6354E-11
Abs(15.09812) = 15.09812
Abs(0) = 0
Abs(-19.06971) = 19.06971
Abs(-1.5058E+18) = 1.5058E+18
Abs(-3.402823E+38) = 3.402823E+38



注:本文中的System.Math.Abs方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
VB.NET Math.Cos方法代码示例发布时间:2022-05-24
下一篇:
VB.NET TimeSpan结构体代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap