ホーム › System.Ole › VarR8Round
VarR8Round
関数倍精度浮動小数点数を指定した小数桁数に丸める。
シグネチャ
// OLEAUT32.dll
#include <windows.h>
HRESULT VarR8Round(
DOUBLE dblIn,
INT cDecimals,
DOUBLE* pdblResult
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| dblIn | DOUBLE | in |
| cDecimals | INT | in |
| pdblResult | DOUBLE* | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// OLEAUT32.dll
#include <windows.h>
HRESULT VarR8Round(
DOUBLE dblIn,
INT cDecimals,
DOUBLE* pdblResult
);[DllImport("OLEAUT32.dll", ExactSpelling = true)]
static extern int VarR8Round(
double dblIn, // DOUBLE
int cDecimals, // INT
out double pdblResult // DOUBLE* out
);<DllImport("OLEAUT32.dll", ExactSpelling:=True)>
Public Shared Function VarR8Round(
dblIn As Double, ' DOUBLE
cDecimals As Integer, ' INT
<Out> ByRef pdblResult As Double ' DOUBLE* out
) As Integer
End Function' dblIn : DOUBLE
' cDecimals : INT
' pdblResult : DOUBLE* out
Declare PtrSafe Function VarR8Round Lib "oleaut32" ( _
ByVal dblIn As Double, _
ByVal cDecimals As Long, _
ByRef pdblResult As Double) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
VarR8Round = ctypes.windll.oleaut32.VarR8Round
VarR8Round.restype = ctypes.c_int
VarR8Round.argtypes = [
ctypes.c_double, # dblIn : DOUBLE
ctypes.c_int, # cDecimals : INT
ctypes.POINTER(ctypes.c_double), # pdblResult : DOUBLE* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OLEAUT32.dll')
VarR8Round = Fiddle::Function.new(
lib['VarR8Round'],
[
Fiddle::TYPE_DOUBLE, # dblIn : DOUBLE
Fiddle::TYPE_INT, # cDecimals : INT
Fiddle::TYPE_VOIDP, # pdblResult : DOUBLE* out
],
Fiddle::TYPE_INT)#[link(name = "oleaut32")]
extern "system" {
fn VarR8Round(
dblIn: f64, // DOUBLE
cDecimals: i32, // INT
pdblResult: *mut f64 // DOUBLE* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OLEAUT32.dll")]
public static extern int VarR8Round(double dblIn, int cDecimals, out double pdblResult);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLEAUT32_VarR8Round' -Namespace Win32 -PassThru
# $api::VarR8Round(dblIn, cDecimals, pdblResult)#uselib "OLEAUT32.dll"
#func global VarR8Round "VarR8Round" double, sptr, sptr
; VarR8Round dblIn, cDecimals, varptr(pdblResult) ; 戻り値は stat
; dblIn : DOUBLE -> "double"
; cDecimals : INT -> "sptr"
; pdblResult : DOUBLE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "OLEAUT32.dll" #cfunc global VarR8Round "VarR8Round" double, int, var ; res = VarR8Round(dblIn, cDecimals, pdblResult) ; dblIn : DOUBLE -> "double" ; cDecimals : INT -> "int" ; pdblResult : DOUBLE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "OLEAUT32.dll" #cfunc global VarR8Round "VarR8Round" double, int, sptr ; res = VarR8Round(dblIn, cDecimals, varptr(pdblResult)) ; dblIn : DOUBLE -> "double" ; cDecimals : INT -> "int" ; pdblResult : DOUBLE* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT VarR8Round(DOUBLE dblIn, INT cDecimals, DOUBLE* pdblResult) #uselib "OLEAUT32.dll" #cfunc global VarR8Round "VarR8Round" double, int, var ; res = VarR8Round(dblIn, cDecimals, pdblResult) ; dblIn : DOUBLE -> "double" ; cDecimals : INT -> "int" ; pdblResult : DOUBLE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT VarR8Round(DOUBLE dblIn, INT cDecimals, DOUBLE* pdblResult) #uselib "OLEAUT32.dll" #cfunc global VarR8Round "VarR8Round" double, int, intptr ; res = VarR8Round(dblIn, cDecimals, varptr(pdblResult)) ; dblIn : DOUBLE -> "double" ; cDecimals : INT -> "int" ; pdblResult : DOUBLE* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"math"
"golang.org/x/sys/windows"
"unsafe"
)
var (
oleaut32 = windows.NewLazySystemDLL("OLEAUT32.dll")
procVarR8Round = oleaut32.NewProc("VarR8Round")
)
// dblIn (DOUBLE), cDecimals (INT), pdblResult (DOUBLE* out)
r1, _, err := procVarR8Round.Call(
uintptr(math.Float64bits(dblIn)),
uintptr(cDecimals),
uintptr(pdblResult),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULT
// 注意: float/double 引数は proc.Call では XMM レジスタに渡せません。
// windows.SyscallN(proc.Addr(), math.Float64bits(x), ...) もしくは cgo を使用してください。function VarR8Round(
dblIn: Double; // DOUBLE
cDecimals: Integer; // INT
pdblResult: Pointer // DOUBLE* out
): Integer; stdcall;
external 'OLEAUT32.dll' name 'VarR8Round';result := DllCall("OLEAUT32\VarR8Round"
, "Double", dblIn ; DOUBLE
, "Int", cDecimals ; INT
, "Ptr", pdblResult ; DOUBLE* out
, "Int") ; return: HRESULT●VarR8Round(dblIn, cDecimals, pdblResult) = DLL("OLEAUT32.dll", "int VarR8Round(double, int, void*)")
# 呼び出し: VarR8Round(dblIn, cDecimals, pdblResult)
# dblIn : DOUBLE -> "double"
# cDecimals : INT -> "int"
# pdblResult : DOUBLE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。