本文介绍了float数组,float []和double []是否不同或相同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写我的代码,好像它们都是一样的,并且没有问题,但是当我将鼠标悬停在Visual Studio中的函数上并看到类型定义包含3种不同的类型时,这开始使我感到困惑原以为都是一样的.他们是一样的吗?还是不同?

I'm writing my code as if these are all the same thing, and having no problems, but it's starting to confuse me when I hover over a function in Visual Studio and see that the type definitions contain 3 different types that I had thought were all the same. Are they the same? Or are they different?

推荐答案

它们是相同的.请参阅 FSharp.Core 文档. float = double = System.Double array<'T>='T [] .您还可以定义自己的类型缩写,并以相同的方式使用它们:

They are the same. See the type abbreviations at the bottom of the FSharp.Core documentation. float = double = System.Double and array<'T> = 'T[]. You can also define your own type abbreviations and use them the same way:

type dbl = double
let (d:dbl) = 1.0

您没有询问它,但是请注意,类型缩写可能无法像您期望的那样工作的地方是度量类型. float< _> 的定义独立于 float double System.Double ,并且没有这样的东西作为相应的 double< _> System.Double< _> .

You didn't ask about it, but note that the one place where type abbreviations might not work quite like you'd expect is measure types; float<_> is defined independently of float, double, and System.Double, and there's no such thing as a corresponding double<_> or System.Double<_>.

这篇关于float数组,float []和double []是否不同或相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 08:32