在 mips 中组合字符

发布于 2024-09-03 02:19:59 字数 99 浏览 2 评论 0原文

我想知道是否有办法将两个字符组合成一个字符。 例如,我有字符 6 和 7 ,我想将它们组合起来并将结果 67 保存在寄存器中,这个问题有什么解决方案吗?

//提前谢谢

i was wondering if there was anyway of combining two characters to form one character.
For instance, i have the character 6 and 7 , i want to combine them and make the result 67 that is saved in a register, is there any solution to this problem ?

//Thx in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

断桥再见 2024-09-10 02:19:59

你的意思是你想存储一串数字字符的数值?

如果是这样,您可以获取每个字符的 ASCII 值(执行必要的检查以确保它在适当的范围内),从中减去“0”的值,然后乘以 10 的位置次方(以相反的顺序编号) ,从 0 开始),然后将其添加到总值中。

例如:

"67" -> 54, 55 -> (54-48)*10^1, (55-48)*10^0 -> (6*10)+(7*1) = 67

Do you mean you want to store the numerical value of a string of digit characters?

If so, you can take each character's ASCII value (perform the necessary checking to make sure it's in the appropriate range), subtract the value of '0' from it, multiply it by 10 to the power of its position (numbered in reverse order, starting from 0) and then add it to a total value.

For example:

"67" -> 54, 55 -> (54-48)*10^1, (55-48)*10^0 -> (6*10)+(7*1) = 67
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文