我怎样才能用Fortran实现BCD?

问题描述:

如果我的问题的标题是有道理的,所以容忍我不知道。我想找到用尽可能少的比特地重新presenting的个位数的系统。有一个叫密密麻麻的十进制的方法( https://en.wikipedia.org/wiki/Densely_packed_decimal ),这将是我的理想的解决方案,但我不知道如果这是可能的,或者我怎么能实现它没有从大师的进一步研究或指导。

Not sure if the title of my question makes sense, so bear with me. I'd like to find a system for representing single digit numbers with as few bits as possible. There is a method called "Densely packed decimal" (https://en.wikipedia.org/wiki/Densely_packed_decimal) which would be my ideal solution, but I wouldn't even know if that's possible or how I could implement it without further research or guidance from a guru.

退而求其次,将能够使用一个4位寻址系统重新present数字,但我再次我不知道这甚至有可能。

The next best thing would be to be able to use a 4-bit addressing system to represent digits, but once again I'm not sure if that is even possible.

所以!限制上述方法/系统的实现方式中,我可以解决所我可以用重新两个整数的present对的1字节的数据类型。有1字节的数据类型在Fortran或它不允许控制的该级别?

So! Barring implementations of the above methods/systems, I could settle for a 1-byte data type which I could use to represent pairs of two integers. Is there a 1-byte data-type in Fortran, or does it not allow for that level of control?

有是(几乎)所有的编程语言中的1个字节的数据类型。它是字符。它实际上是一个字节的定义,它可以容纳一个默认的字符。

There is a 1 byte datatype in (almost) every programming language. It is the character. It is actually the definition of a byte, that it can hold a default character.

还有一个1字节(严格地说1字节)的Fortran语言整数类型,访问为整数(INT8),其中 INT8 是从 iso_fortran_env 模块恒定的(2008年的Fortran)。

There is also a 1-byte (strictly speaking 1-octet) integer type in Fortran, accessible as integer(int8) where int8 is a constant from the iso_fortran_env module (Fortran 2008).

两者都可以用来实现这样的事情。无论你将使用除以其它数字,异或或Fortran位操作内部函数的 https://www.nsc.liu.se/~boein/f77to90/a5.html#section10 (可能是最好的选择)是取决于你。

Both can be used to implement such things. Whether you will use division by other numbers, xoring, or Fortran bit manipulation intrinsic functions https://www.nsc.liu.se/~boein/f77to90/a5.html#section10 (probably the best option) is up to you.