Skip to content

Fixed display problems of uint32 type during go test #249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2022

Conversation

tyd2000
Copy link
Contributor

@tyd2000 tyd2000 commented Jun 27, 2022

修复了题目190和191运行go test时,uint32类型的显示问题。

for _, q := range qs {
      _, p := q.ans190, q.para190
      input := strconv.FormatUint(uint64(p.one), 2) // 32位无符号整数转换为二进制字符串
      input = fmt.Sprintf("%0*v", 32, input)        // 格式化输出32位,保留前置0
      output := reverseBits(p.one)
      outputBin := strconv.FormatUint(uint64(output), 2) // 32位无符号整数转换为二进制字符串
      outputBin = fmt.Sprintf("%0*v", 32, outputBin)     // 格式化输出32位,保留前置0
      fmt.Printf("【input】:%v       【output】:%v (%v)\n", input, output, outputBin)
}

这样在go test时就能与力扣官网的输入输出显示一致啦。望大佬采纳!

~/LeetCode-Go/leetcode/0190.Reverse-Bits$ go test
------------------------Leetcode Problem 190------------------------
【input】:00000010100101000001111010011100       【output】:964176192 (00111001011110000010100101000000)
【input】:11111111111111111111111111111101       【output】:3221225471 (10111111111111111111111111111111)



PASS
ok      github.com/halfrost/LeetCode-Go/leetcode/0190.Reverse-Bits      0.164s

@halfrost halfrost merged commit 1793f49 into halfrost:master Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants