gpt4 book ai didi

c# - 将 float 转换为整数

转载 作者:行者123 更新时间:2023-11-30 18:52:27 27 4
gpt4 key购买 nike

<分区>

所以我有一个正在做的项目。这是我遇到的唯一错误:

Cannot implicitly convert type 'float' to 'int'.

我有点明白那是什么意思。我只需要帮助将我的 float 转换为整数。

这只是其中一个 float 的示例:

float key = 0.5f;
int key = 53;

具体代码部分如下:

// price in scrap, e.g. 29 / 9 = 3.33 ref
static int BuyPricePerTOD = 21;
// price in scrap, e.g. 31 / 9 = 3.55 ref
static float SellPricePerTOD = BuyPricePerTOD + 0.5F;

static int BuyPricePerKey = 53;
static float SellPricePerKey = BuyPricePerKey + 0.5F;

static int TimerInterval = 170000;
static int InviteTimerInterval = 2000;

int UserWeapAdded,UserScrapAdded,UserRecAdded,UserRefAdded,
UserKeysAdded,UserTODAdded,BotTODsAdded,BotKeysAdded,
BotScrapAdded,BotRecAdded,BotRefAdded,InventoryMetal,
InventoryScrap,InventoryRec,InventoryRef,InventoryKeys,
InventoryTOD,PreviousTODs,PreviousKeys,WhileLoop,InvalidItem = 0;

float UserMetalAdded, BotMetalAdded, OverpayNumKeys,
OverpayNumTOD, ExcessInScrapKey, ExcessInScrapTOD = 0.0F;
double ExcessRefinedKey, ExcessRefinedTOD = 0.0;

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com