VB6中的模数是破坏还是奇数? [英] Is modulo in VB6 broken or just odd?

查看:136
本文介绍了VB6中的模数是破坏还是奇数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

-24 mod 7 = -3


根据我大学的教授,数学模数不能返回小于0的值,但Visual Basic 6中的函数确实如此。


有没有快速解决这个问题?

-24 mod 7 = -3

The mathematical modulo can''t return a value less than 0 according to the professors at my University but the function in Visual Basic 6 does.

Is there a fast way around this problem?

推荐答案

当然 - 使用 Abs()在使用 Mod()之前或之后获取绝对值的函数。
Sure - use the Abs() function to get the absolute value, either before or after using Mod().


你的意思是abs(a mod b)还是abs(a )mod b?


无论如何都会逆转它。
Did you mean abs(a mod b) or abs(a) mod b?

That would reverse it either way.



你的意思是abs (a mod b)或abs(a)mod b?


这会以任何方式扭转它。
Did you mean abs(a mod b) or abs(a) mod b?

That would reverse it either way.



是的,这就是我所指的之前或之后。只要它产生了预期的结果,我就不会发现你走哪条路会有什么不同。

Yeah, that''s what I meant by "before or after". As long as it produces the desired result, I don''t see that it makes any difference which way you go.


这篇关于VB6中的模数是破坏还是奇数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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