第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Big.Int Div 始終返回 0

Big.Int Div 始終返回 0

Go
有只小跳蛙 2022-09-19 10:11:30
我無法在 Go 中使用 BigInt.Div() 時(shí)獲取值。大整數(shù):    totalAllocPoint, _ := instance_polypup.TotalAllocPoint(&bind.CallOpts{}) //*big.int    fmt.Println("totalAllocPoint: ", totalAllocPoint)// 54000    poolInfoStruct, _ := instance_polypup.PoolInfo(&bind.CallOpts{}, &pid) //*big.int    fmt.Println("allocPoint: ", poolInfoStruct.AllocPoint)// 2000我試圖使用以下代碼進(jìn)行劃分,始終返回0:    poolInfoStruct.AllocPoint.Div(poolInfoStruct.AllocPoint, totalAllocPoint)    fmt.Println("poolAlloc: ", poolInfoStruct.AllocPoint)    poolAlloc := big.NewInt(0).Div(poolInfoStruct.AllocPoint, totalAllocPoint)    fmt.Println("poolAlloc: ", poolAlloc)    poolAlloc := big.NewInt(0)    poolAlloc.Div(poolInfoStruct.AllocPoint, totalAllocPoint)    fmt.Println("poolAlloc: ", poolAlloc)
查看完整描述

1 回答

?
守候你守候我

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超10個(gè)贊

Int.Div() 是一個(gè)整數(shù)除法運(yùn)算。你除以哪個(gè)是.這將永遠(yuǎn)是,因?yàn)槌龜?shù)大于股息。poolInfoStruct.AllocPointtotalAllocPoint2000 / 540000

也許你想要相反的?totalAllocPoint / poolInfoStruct.AllocPoint

請(qǐng)參閱此示例:

totalAllocPoint := big.NewInt(54000)
allocPoint := big.NewInt(2000)

totalAllocPoint.Div(totalAllocPoint, allocPoint)
fmt.Println(totalAllocPoint)

哪個(gè)輸出(在Go游樂場上嘗試)。27

您指出除數(shù)和股息是正確的。如果是這樣,則不能用于此目的,因?yàn)橹荒鼙硎菊麛?shù)。big.Intbig.Int

你可以使用大。例如,浮點(diǎn)數(shù),并使用浮點(diǎn)數(shù).Quo() 來計(jì)算商。

例如:

totalAllocPoint := big.NewInt(54000)
allocPoint := big.NewInt(2000)

tot := big.NewFloat(0).SetInt(totalAllocPoint)
ap := big.NewFloat(0).SetInt(allocPoint)

tot.Quo(ap, tot)
fmt.Println(tot)

輸出(在Go游樂場上嘗試):

0.037037037037037035

另一種選擇是使用大。老鼠老鼠( )

tot := big.NewRat(0, 1).SetInt(totalAllocPoint)
ap := big.NewRat(0, 1).SetInt(allocPoint)

tot.Quo(ap, tot)
fmt.Println(tot)

輸出(在Go游樂場上嘗試):

1/27


查看完整回答
反對(duì) 回復(fù) 2022-09-19
  • 1 回答
  • 0 關(guān)注
  • 82 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)