如何打印十六进制数字在PHP和Java [英] How to Print Hexadecimal Numbers in PHP or Java

查看:405
本文介绍了如何打印十六进制数字在PHP和Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要打印一些数据(有点怪格式化)。我用,如果($ NUM%10 == 9)写在PHP中,但它是不可能的,我得到正确的输出。

I need to print some data (a little bit strange formatted). I was writing it in PHP with if ($num%10==9) but it was impossible for me to get correct output.

那么就来看看本作的例子。 我们有文件x的文件夹中。对于此实施例X = 36。 X的都知道。

So take a look at this for example. We have x of files in folder. For this example x=36. X is always known.

输出应该是这样的:

01
02
03
04
05
06
07
08
09
0a
0b
0c
0d
0e
0f
10
11
...
19
1a
...
1f
20
...
24

对不起,这么长的名单,但我相信,你知道我现在需要的。 这样,每一个与9号结束后,我们有NUM(A,B,C,D,E,F),然后数随后previous号码与9上的末端。 (例3A ... 3F,40..49)。 而最重要的是,打印的行的数量必须等于x

Sorry for the such a long "list" but I believe that you know what I need now. So, after each number which ends with 9 we have num(a,b,c,d,e,f) and then number which follows previous number with 9 on the end. (Ex. 3a...3f,40..49). And what is most important is that the number of printed lines must be equal to x.

如果可能的话,我想preFER PHP和Java code,但我会非常感谢任何形式的帮助。

If possible, I would prefer PHP or Java code but I will be very grateful for any kind of help.

推荐答案

您需要打印的数字1到30的十六进制。试试每行这个方法:

You need to print the numbers 1 to 30 in hexadecimal notation. Try this method for each line:

dechex ( int $number )

这篇关于如何打印十六进制数字在PHP和Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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