modMathTools 函式庫 風禹科技驗證有限公司 網站 提供 .Net 原始碼

CValue 函數

說明

將數值進位或捨去至特定數值

本函數之引數列表

引數 型態 位元組 選項 預設值 說明
vSource Object - 必須 (無) 數值
BiosValue Double 8 可省略 1 階梯函數的間距
wFlags enuStepGauss 4 可省略 SG_Normal 數值進位旗標:
常數名 數值 說明
SG_Normal 0 四捨五入法
SG_Lower 1 無條件捨去法
SG_Upper 2 無條件進位法

BaseValue Double 8 可省略 0 基底,表對 0 的偏差

傳回值

傳回 Double 數值

範例

Debug.WriteLine(CValue(2.5, 4)) ' 傳回 4
Debug.WriteLine(CValue(2.5, 4, modMathTools.enuStepGauss.SG_Lower)) ' 傳回 0
Debug.WriteLine(CValue(2.5, 4, , 2)) ' 傳回 2
Debug.WriteLine(CValue(2.5, 4, modMathTools.enuStepGauss.SG_Upper, 2)) ' 傳回 6
Debug.WriteLine(CValue(2.58, 0.1)) ' 傳回 2.6
Debug.WriteLine(CValue(2.5, , modMathTools.enuStepGauss.SG_Upper)) ' 傳回 3

更進一步

範例如圖,值 2.5 欲轉換至 0, 2, 3, 4, 6 之方法

基本條件

Visual Studio .Net 2002 以後相容版本 | MathTool.vb

請參閱

modMathTools 函式庫 | StepGauss