草庐IT

OES_texture_float

全部标签

c# - 为什么 float.parse 返回错误值?

我有一个问题。当我将像“0.005”这样的字符串解析为float或double时,它在我的电脑上运行良好,但当我将我的程序安装到我的客户端电脑时,它返回5。(我的电脑和我的客户端电脑都使用Windows7x64).这是我的例子publicfloatgetFloat(){floatmn=float.Parse("0.005");doublemn2=Convert.ToDouble("0.005");returnmn;} 最佳答案 这可能是系统文化设置的问题。试试这个:float.Parse("0.005",CultureInfo.In

c# - float 中的E是什么?

什么是E+3?这里到底发生了什么?我们可以在其他数据类型中使用这种方法,还是只能在float中使用它?staticvoidMain(string[]args){doublew=1.7E+3;Console.WriteLine(w);}输出:1700 最佳答案 EnotationMostcalculatorsandmanycomputerprogramspresentverylargeandverysmallresultsinscientificnotation.Becausesuperscriptedexponentslike107

c# - 存在从 'float' 和 'float' 以及从 'float' 到 'float' 的隐式转换

这可能是我一段时间以来收到的最好的错误消息,我很好奇出了什么问题。原代码floatcurrElbowAngle=LeftArm?Elbow.transform.localRotation.eulerAngles.y:360f-Elbow.transform.localRotation.eulerAngles.y我正在使用Unity3d和C#;LeftArm是一个bool类型,根据documentationElbow.transform.localRotation.eulerAngles.y返回一个float值。这段代码给我错误:Thereexistsbothimplicitconver

c# - float 的乘法性能不一致

在.NET中测试float的性能时,我偶然发现了一个奇怪的情况:对于某些值,乘法似乎比正常情况慢得多。这是测试用例:usingSystem;usingSystem.Diagnostics;namespaceNumericPerfTestCSharp{classProgram{staticvoidMain(){Benchmark(()=>float32Multiply(0.1f),"\nfloat32Multiply(0.1f)");Benchmark(()=>float32Multiply(0.9f),"\nfloat32Multiply(0.9f)");Benchmark(()=>f

c# - 从 int 转换为 float 的问题

有一个我无法理解的奇怪行为。同意float是近似值,因此即使显然返回没有小数的数字的操作也可以近似为带小数的数字。我这样做:intnum=(int)(195.95F*100);因为这是一个浮点运算,所以我得到19594而不是19595..但这是正确的。让我困惑的是,如果我这样做floatflo=195.95F*100;intnum=(int)flo;我得到了19595的正确结果。知道为什么会这样吗? 最佳答案 我想看看这是不是编译器在做数学运算,但即使你强制它,它的行为也是这样的:staticvoidMain(){inti=(int

C# float.Parse 字符串

我是C#新手,需要从文件中读取float值(x,y,z)。看起来像:0-0.01-0.0020.000833333333333-0.01-0.002如果我正在尝试floatnumber=float.Parse("0,54");//itworkswell,butfloatnumber=float.Parse("0.54");//gainsexepction.我从每一行读取值的代码(可能有问题):intbegin=0;intend=0;for(inti=0;i有人可以帮忙吗? 最佳答案 float.Parse(string)method

c# - 为什么在将字符串转换为 float 时会出现 FormatException?

当我尝试将字符串转换为float时:Console.WriteLine(float.Parse("6.59"));它抛出一个异常:UnhandledException:System.FormatException:Inputstringwasnotinacorrectformat.atSystem.Number.ParseSingle(Stringvalue,NumberStylesoptions,NumberFormatInfonumfmt)当我这样尝试时:Console.WriteLine(Convert.ToSingle("6.59"));它抛出相同的异常:UnhandledEx

c# - 我需要更快的 .NET C# float 学运算(用于大数组的乘法和除法)

我需要最快的方法来乘除大数据数组。我读过这篇文章(由BenVoigt撰写here):.NETdoesn'tuseMMXorSSEorAVX,asofthecurrentversion(...)modernC++compilersnotonlyallowSIMDusage,butcanauto-vectorizeordinary-lookingcodeintoSIMDinstructions.我想我需要:SSE支持矢量运算(一次乘以4个float)多线程支持(不会以某种方式与C#线程冲突的解决方案/库)有没有我可以使用的库/dll?编辑:Octave的任何替代品?我只需要2个操作:除法、

C# float 转十进制

任何像这样转换float的聪明方法:floatf=711989.98f;在不损失精度的情况下转换为小数(或double)?我试过:decimald=(decimal)f;decimald1=(decimal)(Math.Round(f,2));decimald2=Convert.ToDecimal(f); 最佳答案 太晚了,第8位数字在编译器中丢失了。float类型只能存储7位有效数字。您将不得不重写代码,分配给double或decimal当然可以解决问题。 关于C#float转十进制,

c# - 'System.Collections.Generic.List<float >' does not contain a definition for ' Sum'

我正在尝试使用内置的Sum()函数对float列表求和,但我不断收到此错误:ErrorCS1061:'System.Collections.Generic.List'doesnotcontainadefinitionfor'Sum'andnoextensionmethod'Sum'acceptingafirstargumentoftype'System.Collections.Generic.List'couldbefound(areyoumissingausingdirectiveoranassemblyreference?)(CS1061)我有usingSystem.Collect