bcd

Z80 DAA instruction

别说谁变了你拦得住时间么 提交于 2019-12-20 17:33:08
问题 Apologies for this seemingly minor question, but I can't seem to find the answer anywhere - I'm just coming up to implementing the DAA instruction in my Z80 emulator, and I noticed in the Zilog manual that it is for the purposes of adjusting the accumulator for binary coded decimal arithmetic. It says the instruction is intended to be run right after an addition or subtraction instruction. My questions are: what happens if it is run after another instruction? how does it know what instruction

消息队列activemq

柔情痞子 提交于 2019-12-20 17:14:12
消息队列activemq 首先,我们为什么需要消息队列? 其实就是问问你消息队列都有哪些使用场景,然后你项目里具体是什么场景,说说你在这个场景里用消息队列是什么? 面试官问你这个问题,期望的一个回答是说,你们公司有个什么业务场景,这个业务场景有个什么技术挑战,如果不用MQ可能会很麻烦,但是你现在用了MQ之后带给了你很多的好处! 先说一下消息队列的常见使用场景吧,其实场景有很多,但是比较核心的有3个:解耦、异步、削峰 1.解耦:现场画个图来说明一下 A系统发送个数据到BCD三个系统,接口调用发送,那如果E系统也要这个数据呢?那如果C系统现在不需要了呢?现在A系统又要发送第二种数据了呢?A系统负责人濒临崩溃中。。。再来点更加崩溃的事儿,A系统要时时刻刻考虑BCDE四个系统如果挂了咋办?我要不要重发?我要不要把消息存起来?头发都白了啊。。。 面试技巧 :你需要去考虑一下你负责的系统中是否有类似的场景,就是一个系统或者一个模块,调用了多个系统或者模块,互相之间的调用很复杂,维护起来很麻烦。但是其实这个调用是不需要直接同步调用接口的,如果用MQ给他异步化解耦,也是可以的,你就需要去考虑在你的项目里,是不是可以运用这个MQ去进行系统的解耦。在简历中体现出来这块东西,用MQ作解耦。 2.异步:现场画个图来说明一下, A系统接收一个请求,需要在自己本地写库,还需要在BCD三个系统写库

Most efficient way to convert BCD to binary

前提是你 提交于 2019-12-19 08:10:30
问题 I have the code below to convert a 32 bit BCD value (supplied in two uint halves) to a uint binary value. The values supplied can be up to 0x9999, to form a maximum value of 0x99999999. Is there a better (ie. quicker) way to achieve this? /// <summary> /// Convert two PLC words in BCD format (forming 8 digit number) into single binary integer. /// e.g. If Lower = 0x5678 and Upper = 0x1234, then Return is 12345678 decimal, or 0xbc614e. /// </summary> /// <param name="lower">Least significant

Python, how to decode Binary coded decimal (BCD)

自古美人都是妖i 提交于 2019-12-19 01:17:10
问题 Description of the binary field is: Caller number, expressed with compressed BCD code, and the surplus bits are filled with “0xF” I have tried to print with struct format '16c' and I get: ('3', '\x00', '\x02', '\x05', '\x15', '\x13', 'G', 'O', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff') and if I use '16b' i get (51, 0, 2, 5, 21, 19, 71, 79, -1, -1, -1, -1, -1, -1, -1, -1) . And it is not correct, I should get phone number, and numbers above are invalid. print struct.unpack

7-4 BCD解密(10 分)

风格不统一 提交于 2019-12-17 16:07:47
BCD数是用一个字节来表达两位十进制的数,每四个比特表示一位。所以如果一个BCD数的十六进制是0x12,它表达的就是十进制的12。但是小明没学过BCD,把所有的BCD数都当作二进制数转换成十进制输出了。于是BCD的0x12被输出成了十进制的18了! 现在,你的程序要读入这个错误的十进制数,然后输出正确的十进制数。提示:你可以把18转换回0x12,然后再转换回12。 输入格式: 输入在一行中给出一个[0, 153]范围内的正整数,保证能转换回有效的BCD数,也就是说这个整数转换成十六进制时不会出现A-F的数字。 输出格式: 输出对应的十进制数。 输入样例: 18 输出样例: 12 最开始想法很单纯,想用四位二进制数来表示,但是实现起来麻烦的一 后来想到,每四位如果用十进制表示,就只需要乘除10。如果用16进制表示,就只需要乘除16。 所以就可以分为两部分,够16的一部分和不够16的一部分,分别用Front和Back表示。 # include <iostream> # include <cmath> # include <climits> # include <iomanip> int main ( void ) { using namespace std ; int errorNum ; cin >> errorNum ; int Front = errorNum / 16 ;

Java code or lib to decode a binary-coded decimal (BCD) from a String

南楼画角 提交于 2019-12-13 13:18:21
问题 I have a string consisting of 1's ('\u0031') and 0's('\u0030') that represents a BCD value. Specifically, the string is 112 characters worth of 1's and 0's and I need to extract either 8 or 16 of these at a time and decode them from BCD to decimal. Ideas? Packages? Libs? Code? All is welcome. 回答1: Extracting 4 characters at a time and use Integer.parseInt(string, 2) should give each digit. Combine the digits as you see fit. 回答2: I think you're missing all the fun: Here's a basic

Decode a Binary Coded Decimal

99封情书 提交于 2019-12-13 05:13:55
问题 I have a field pic X(03) with a date in it as X'160101' format yymmdd. I will like to know how to convert it to pic x(06). So far I tried to move it back to a 9(03) comp and move the 9(03) comp to a 9(06) but it didn't work. How can I do this? 回答1: If you search stackoverflow, you should find the answer (this has already been answered). But Create a fields like (my-date-x holds the date): 03 my-date-x pic x(3). 03 my-date-9 pic 9(6). 03 date-ymdv0 pic 9(6)v9 comp-3. 03 date-x pic x(3)

Conversion from Integer to BCD

懵懂的女人 提交于 2019-12-13 04:49:33
问题 I want to convert the integer (whose maximum value can reach to 99999999) in to BCD and store in to array of 4 characters. Like for example: Input is : 12345 (Integer) Output should be = "00012345" in BCD which is stored in to array of 4 characters. Here 0x00 0x01 0x23 0x45 stored in BCD format. I tried in the below manner but didnt work int decNum = 12345; long aux; aux = (long)decNum; cout<<" aux = "<<aux<<endl; char* str = (char*)& aux; char output[4]; int len = 0; int i = 3; while (len <

Binary coded decimals in verilog

瘦欲@ 提交于 2019-12-13 02:23:03
问题 I wrote the following code for BCD to seven segment. The code compiles find and simulates too but the value of num is not going beyond 2. I don't know why is that. Here is the code: module BCDtoSeven_TOP reg [3:0] num; wire a,b,c,d,e,f,g; BCDtoSeven s(num,a,b,c,d,e,f,g); initial begin num=1; end always @(num<=9) begin #2 num=num+1; end endmodule Sub Module: module BCDtoSeven(num,a,b,c,d,e,f,g); output a,b,c,d,e,f,g; input [3:0] num; assign a=(num==4 || num==5 || num==6 || num==7 || num==8 ||

How can I implement BCD in Fortran?

这一生的挚爱 提交于 2019-12-12 01:58:22
问题 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. The next best thing would be to be able to use a 4-bit addressing system to