如何在C中创建一个将float类型转换为字符串的函数 [英] How to create a function to covert float type to string in C
本文介绍了如何在C中创建一个将float类型转换为字符串的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
float t=5467453265.457;
int i,d;
i=(int)t;
//itos();
t=t-(int)t;
t*=1000000;
//precision
d=t;
//itos()
我尝试了什么:
i试图分别读取其整数部分小数部分,但是如果int部分大于int的范围,则代码不起作用
What I have tried:
i have tried to read its integer part n decimal part separately but code don't work if int part is greater than range of int
推荐答案
签出:快速准确地打印浮点数 [ ^ ]由我的朋友Robert Burger
Check out: Printing Floating-Point Numbers Quickly and Accurately[^] by my friend Robert Burger
这篇关于如何在C中创建一个将float类型转换为字符串的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文