feat(App.vue): 添加 `getMaxNumber` 函数,用于计算最大无符号数字

This commit is contained in:
conglinyizhi 2024-10-06 20:57:17 +08:00
parent 4774ddea6f
commit 032e8d694d
1 changed files with 7 additions and 1 deletions

View File

@ -1,6 +1,7 @@
<template> <template>
<div> <div>
{{ selectIndex }} M{{ selectIndex }}.0 开始占用 {{ selectIndexWidth + 1 }} Byte最大可以表示无符号数字 {{ (selectIndexWidth + 1) * 8 }}
{{ getMaxNumber() }}
<button @click="selectIndexWidth = 0"> <button @click="selectIndexWidth = 0">
<span v-show="selectIndexWidth == 0">激活=></span>MB</button> <span v-show="selectIndexWidth == 0">激活=></span>MB</button>
<button @click="selectIndexWidth = 1"> <button @click="selectIndexWidth = 1">
@ -29,6 +30,11 @@ function getClassName(i) {
if (Math.min(min, i) === min && Math.max(max, i) === max) return 'select' if (Math.min(min, i) === min && Math.max(max, i) === max) return 'select'
return '' return ''
} }
function getMaxNumber() {
const bin = '1'.repeat((selectIndexWidth.value + 1) * 8)
return Number.parseInt(bin, 2)
}
</script> </script>
<style lang="scss"> <style lang="scss">