如何使用天花板,地板数学函数| VB.NET [英] How do I use ceiling , floor math functions | VB.NET

查看:130
本文介绍了如何使用天花板,地板数学函数| VB.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

再次问好,我需要在我的问题中使用这些数学函数。



首先,我有一个值列表,首先我使用abs和log10数学函数。

现在,我需要在该数组中使用这2个方程。



1. x = ceil(30 * log10 (arrData))+ 1

2. y = floor(30 * log10(arrData))



然后,我需要制作这个计算:newsetdata = y-x + 1



我创建了2个列表,第一个是使用了天花板的arrData,而arrData2是底层。 br />


现在我想创建一个新列表,我可以使用这个等式 - > arrData2-arrData + 1我无法做到这一点...一些帮助?



我尝试了什么:



Hello again, I need to use these math functions in my problem.

First of all, I have an list of values which first I use the abs and log10 math functions.
Now, I need to use these 2 equations in that array.

1. x=ceil(30*log10(arrData))+1
2. y=floor(30*log10(arrData))

And then, I need to make this calculation : newsetdata=y-x+1

I create 2 lists, the 1st is the arrData which I used the ceiling , and the arrData2 is the floor.

now I want to create a new list that I can use this equation -> arrData2-arrData+1 and I can't do this...some help?

What I have tried:

Dim strFileName = IO.File.ReadAllLines("C:\Users\x-ios\Desktop\1234.txt")
Dim cu As Globalization.CultureInfo = Globalization.CultureInfo.CreateSpecificCulture("en-US")
Dim style As Globalization.NumberStyles = Globalization.NumberStyles.Number Or Globalization.NumberStyles.AllowCurrencySymbol

Dim arrData = strFileName _
.Select(Function(x) New With _
{
.FirstCol = Math.Ceiling(Math.log10(Math.Abs(Double.Parse(x.Split(New String(){Microsoft.VisualBasic.vbTab}, StringSplitOptions.RemoveEmptyEntries)(0), style, cu))), _
.SecondCol = Math.Ceiling(Math.log10(Math.Abs(Double.Parse(x.Split(New String(){Microsoft.VisualBasic.vbTab}, StringSplitOptions.RemoveEmptyEntries)(1), style, cu)))) _
}) _
.ToList()


Dim arrData2 = strFileName _
.Select(Function(x) New With _
{
.FirstCol = Math.Floor(Math.log10(Math.Abs(Double.Parse(x.Split(New String(){Microsoft.VisualBasic.vbTab}, StringSplitOptions.RemoveEmptyEntries)(0), style, cu)))), _
.SecondCol = Math.Floor(Math.log10(Math.Abs(Double.Parse(x.Split(New String(){Microsoft.VisualBasic.vbTab}, StringSplitOptions.RemoveEmptyEntries)(1), style, cu)))) _
}) _
.ToList()

推荐答案

Quote:

是的,我提到x = ceil(30 * log10(arrData))+ 1,y = floor(30 * log10(arrData) )),我完成了它们(arrData是x,y是arrData2)。现在我需要:newdataset = y-x + 1

(我更新问题,因为我忘了提到它,错误)

Yes, I mentioned that x=ceil(30*log10(arrData))+1 , y=floor(30*log10(arrData)), and I accomplished them (arrData is the x ,and y is the arrData2) . And now I need : newdataset=y-x+1
(I update the question, because I forgot to mentioned it, by mistake)





计算结果所需的全部是:



All you need to calculate result is:

Dim arrData = strFileName _
	.Select(Function(x) New With _
		{
			.a = Double.Parse(x.Split(New String(){Microsoft.VisualBasic.vbTab}, StringSplitOptions.RemoveEmptyEntries)(0), style, cu), _
			.b = Double.Parse(x.Split(New String(){Microsoft.VisualBasic.vbTab}, StringSplitOptions.RemoveEmptyEntries)(1), style, cu) _
		}) _
	.ToList()

	For Each d In arrData
		Dim x = Math.Ceiling(30*Math.Log10(d.a))+1
		Dim y = Math.Floor(30*Math.Log10(d.b)) 
		Console.WriteLine("{0}-{1}+1={2}", y, x, y-x+1)
	Next





Reult:



Reult:

-11--38+1=28
-8--35+1=28
-5--33+1=29
-3--31+1=29
-1--30+1=30
0--29+1=30
...





如果我误解了您,请根据需要更改代码。



Change the code to your needs, if i misunderstood you.


这篇关于如何使用天花板,地板数学函数| VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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