将一种数据类型转换为另一种 [英] convert one data type to another

查看:112
本文介绍了将一种数据类型转换为另一种的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对命令式语言及其特征非常熟悉。所以,我想知道如何将一种数据类型转换为另一种?

的static_cast<> c
(data_type)中的
< another_data_type>


解决方案

使用显式强制功能。 b
$ b

例如,来自整数的将转换任何积分类型( Int Integer Word * 等)转换成任何数字类型。

您可以使用 Hoogle 查找实际的功能,适合你的需要,按其类型。


I am so familiar with imperative language and their features. So, I wonder how I can convert one data type to another?

ex:
   in c++
           static_cast<>
    in c
           ( data_type) <another_data_type>

解决方案

Use an explicit coercion function.

For example, fromIntegral will convert any Integral type (Int, Integer, Word*, etc.) into any numeric type.

You can use Hoogle to find the actual function that suits your need by its type.

这篇关于将一种数据类型转换为另一种的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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