- 210832gl2lpad2eeia9l1d.png (106.91 KiB) 已瀏覽 7787 次
FileMaker 常用数值函数使用簡介
版主: 發記
FileMaker 常用数值函数使用簡介
FileMaker 常用数值函数使用簡介
Re: FileMaker 常用数值函数使用簡介
——————————————————————————————————————————————————
Round 與 Truncate
——————————————————————————————————————————————————
函数:Round
目的:返回一个四舍五入到指定精度(小数位数)的数字
格式:Round ( 数字 ; 精度 )
示例
Round ( 123.454 ; 0 ) = 123
Round ( 123.554 ; 0 ) = 124
Round ( -123.454 ; 0 ) = -123
Round ( -123.554 ; 0 ) = -124
Round ( 123.454 ; 2 ) = 123.45
Round ( 123.455 ; 2 ) = 123.46
Round ( 1249.45 ; -2 ) = 1200
Round ( 1250.45 ; -2 ) = 1300
Round ( 10 / 3 ; 2 ) = 3.33
Round ( 10 / 3 ; 3 ) = 3.333
——————————————————————————————————————————————————
函数:Truncate
返回:一个截取到指定小数位数的数字。
格式:Truncate ( 数字 ; 精度 )
示例
Truncate ( 123.454 ; 0 ) = 123
Truncate ( 123.554 ; 0 ) = 123
Truncate ( -123.454 ; 0 ) = -123
Truncate ( -123.554 ; 0 ) = -123
Truncate ( 123.454 ; 2 ) = 123.45
Truncate ( 123.455 ; 2 ) = 123.45
Truncate ( 1249.45 ; -2 ) = 1200
Truncate ( 1250.45 ; -2 ) = 1200
Truncate ( 10 / 3 ; 2 ) = 3.33
Truncate ( 10 / 3 ; 3 ) = 3.333
Round 與 Truncate
——————————————————————————————————————————————————
函数:Round
目的:返回一个四舍五入到指定精度(小数位数)的数字
格式:Round ( 数字 ; 精度 )
示例
Round ( 123.454 ; 0 ) = 123
Round ( 123.554 ; 0 ) = 124
Round ( -123.454 ; 0 ) = -123
Round ( -123.554 ; 0 ) = -124
Round ( 123.454 ; 2 ) = 123.45
Round ( 123.455 ; 2 ) = 123.46
Round ( 1249.45 ; -2 ) = 1200
Round ( 1250.45 ; -2 ) = 1300
Round ( 10 / 3 ; 2 ) = 3.33
Round ( 10 / 3 ; 3 ) = 3.333
——————————————————————————————————————————————————
函数:Truncate
返回:一个截取到指定小数位数的数字。
格式:Truncate ( 数字 ; 精度 )
示例
Truncate ( 123.454 ; 0 ) = 123
Truncate ( 123.554 ; 0 ) = 123
Truncate ( -123.454 ; 0 ) = -123
Truncate ( -123.554 ; 0 ) = -123
Truncate ( 123.454 ; 2 ) = 123.45
Truncate ( 123.455 ; 2 ) = 123.45
Truncate ( 1249.45 ; -2 ) = 1200
Truncate ( 1250.45 ; -2 ) = 1200
Truncate ( 10 / 3 ; 2 ) = 3.33
Truncate ( 10 / 3 ; 3 ) = 3.333
Re: FileMaker 常用数值函数使用簡介
——————————————————————————————————————————————————
Int, Mod 與 Div
——————————————————————————————————————————————————
函数:Int
目的:去掉小数点右边的数字,不四舍五入,返回数字的整数部分。
格式:Int ( 数字 )
示例
Int ( 10 / 3 ) = 3
Int ( 210 / 4 ) = 52
Int ( 123.454 ) = 123
Int ( -123.454 ) = -123
——————————————————————————————————————————————————
函数:Mod
目的:返回某数字除以除数后所得的余数
格式
Mod ( 数字 ; 除数 )
示例
Mod ( 10 ; 3 ) = 1
Mod ( 210 ; 4 ) = 2
Mod ( 123.454 ; 1 ) = 0.454
Mod ( -123.454 ; 1 ) = 0.546
——————————————————————————————————————————————————
函数:Div
目的:返回数字除以除数所得商的下一个最小整数值
格式
Div ( 数字 ; 除数 )
示例
Div ( 10 ; 3 ) = 3
Div ( 210 ; 4 ) = 52
Div ( 123.454 ; 1 ) = 123
Div ( -123.454 ; 1 ) = -124
Int, Mod 與 Div
——————————————————————————————————————————————————
函数:Int
目的:去掉小数点右边的数字,不四舍五入,返回数字的整数部分。
格式:Int ( 数字 )
示例
Int ( 10 / 3 ) = 3
Int ( 210 / 4 ) = 52
Int ( 123.454 ) = 123
Int ( -123.454 ) = -123
——————————————————————————————————————————————————
函数:Mod
目的:返回某数字除以除数后所得的余数
格式
Mod ( 数字 ; 除数 )
示例
Mod ( 10 ; 3 ) = 1
Mod ( 210 ; 4 ) = 2
Mod ( 123.454 ; 1 ) = 0.454
Mod ( -123.454 ; 1 ) = 0.546
——————————————————————————————————————————————————
函数:Div
目的:返回数字除以除数所得商的下一个最小整数值
格式
Div ( 数字 ; 除数 )
示例
Div ( 10 ; 3 ) = 3
Div ( 210 ; 4 ) = 52
Div ( 123.454 ; 1 ) = 123
Div ( -123.454 ; 1 ) = -124
Re: FileMaker 常用数值函数使用簡介
——————————————————————————————————————————————————
Random
——————————————————————————————————————————————————
函数:Random
目的:返回一个介于 0 和 1 之间的数字,包含 0 但不包含 1
示例
假設 Random = 0
Random * 10 = 0
Round ( Random * 10 ; 0 ) = 0
Int ( Random * 10 ) = 0
假設 Random = .45183393636025736217
Random * 10 = 4.5183393636025736217
Round ( Random * 10 ; 0 ) = 5
Int ( Random * 10 ) = 4
假設 Random = .99999999999999999999
Random * 10 = 9.9999999999999999999
Round ( Random * 10 ; 0 ) = 10
Int ( Random * 10 ) = 9
——————————————————————————————————————————————————
假設 Random = 0
Random * 15 = 0
Round ( Random * 15 ; 0 ) = 0
Int ( Random * 15 ) = 0
假設 Random = .45183393636025736217
Random * 15 = 6.77750904540386043255
Round ( Random * 15 ; 0 ) = 7
Int ( Random * 15 ) = 6
假設 Random = .99999999999999999999
Random * 15 = 14.99999999999999999985
Round ( Random * 15 ; 0 ) = 15
Int ( Random * 15 ) = 14
——————————————————————————————————————————————————
算出 0 - 10 之間的隨機數:Round ( Random * 10 ; 0 )
算出 0 - 9 之間的隨機數:Int ( Random * 10 )
算出 1 - 10 之間的隨機數:Int ( Random * 10 ) + 1
算出 0 - 15 之間的隨機數:Round ( Random * 15 ; 0 )
算出 0 - 14 之間的隨機數:Int ( Random * 15 )
算出 1 - 15 之間的隨機數:Int ( Random * 15 ) + 1
算出 0.00 - 15.00 之間的隨機數:Round ( Random * 15 ; 2 )
算出 30.00 - 45.00 之間的隨機數:Round ( Random * 15 ; 2 ) + 30
Random
——————————————————————————————————————————————————
函数:Random
目的:返回一个介于 0 和 1 之间的数字,包含 0 但不包含 1
示例
假設 Random = 0
Random * 10 = 0
Round ( Random * 10 ; 0 ) = 0
Int ( Random * 10 ) = 0
假設 Random = .45183393636025736217
Random * 10 = 4.5183393636025736217
Round ( Random * 10 ; 0 ) = 5
Int ( Random * 10 ) = 4
假設 Random = .99999999999999999999
Random * 10 = 9.9999999999999999999
Round ( Random * 10 ; 0 ) = 10
Int ( Random * 10 ) = 9
——————————————————————————————————————————————————
假設 Random = 0
Random * 15 = 0
Round ( Random * 15 ; 0 ) = 0
Int ( Random * 15 ) = 0
假設 Random = .45183393636025736217
Random * 15 = 6.77750904540386043255
Round ( Random * 15 ; 0 ) = 7
Int ( Random * 15 ) = 6
假設 Random = .99999999999999999999
Random * 15 = 14.99999999999999999985
Round ( Random * 15 ; 0 ) = 15
Int ( Random * 15 ) = 14
——————————————————————————————————————————————————
算出 0 - 10 之間的隨機數:Round ( Random * 10 ; 0 )
算出 0 - 9 之間的隨機數:Int ( Random * 10 )
算出 1 - 10 之間的隨機數:Int ( Random * 10 ) + 1
算出 0 - 15 之間的隨機數:Round ( Random * 15 ; 0 )
算出 0 - 14 之間的隨機數:Int ( Random * 15 )
算出 1 - 15 之間的隨機數:Int ( Random * 15 ) + 1
算出 0.00 - 15.00 之間的隨機數:Round ( Random * 15 ; 2 )
算出 30.00 - 45.00 之間的隨機數:Round ( Random * 15 ; 2 ) + 30
誰在線上
正在瀏覽這個版面的使用者:沒有註冊會員 和 10 位訪客