简称toHexString [英] Short toHexString

查看:121
本文介绍了简称toHexString的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有方法 Integer.toHexString() Long.toHexString()。由于某种原因,他们没有实现 Short.toHexString()

There are methods Integer.toHexString() and Long.toHexString(). For some reason they didn't implement Short.toHexString().

将Short转换为十六进制字符串的规范方法是什么?

What is the canonical method converting Short to a hex string?

无法使用 Integer.toHexString()因为 Integer.toHexString( - 33)等于 ffffffdf 这不是一个短值。

It's not possible to use Integer.toHexString() because Integer.toHexString(-33) equals ffffffdf which is not a short value.

推荐答案

如果你的系统表示为16Bit,你也可以简单地执行以下操作。

If in your system short is represented as 16Bit you can also simply do the following.

String hex = Integer.toHexString(-33 & 0xffff);

这篇关于简称toHexString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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