数字中逗号的含义 [英] Meaning of a comma in a number

查看:89
本文介绍了数字中逗号的含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
C++ 逗号运算符

这可能是一个微不足道的问题,但我不知道答案.今天下午这一直困扰着我.

that probably a trivial question, but I don't know the answer. And this has been troubling me this afternoon.

我只是在写一个函数来将 RVB 转换为 YUV.没什么特别的,但在我的数字中错误地使用了逗号 (,) 而不是点.

I was just writing a function to convert RVB to YUV. Nothing really special, but mistakenly used the comma (,) instead of a dot in my numbers.

它编译但结果不是我预期的,例如-3713796"而不是 0-255 范围数字.

It compiles but the result was not what I expected, for example "-3713796" instead of a 0-255 range number.

(0,615*(double) 61) - (0,51498*(double) 61) - (0,10001*(double) 61)

那是什么意思?
如果它不是编译错误,它可能对某些东西有用,但是什么?

So what does it mean ?
If it's not a compilation error, it's probably usefull for something but what?

Ps:我在 Qt 中使用 C++.

Ps: I was using C++ with Qt.

推荐答案

您不小心使用了逗号操作员.它计算第一个操作数并丢弃结果,然后计算第二个操作数并返回其值和类型.

You've accidentally used the comma operator. It evaluates its first operand and discards the result, and then evaluates the second operand and returns its value and type.

根据我的经验,它最常用于循环语句中.对于其他用途,请参阅C 逗号运算符的使用

In my experience, it's most commonly used in loop statements. For other uses, see Uses of C comma operator

这篇关于数字中逗号的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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