الدوال الحسابية
تتّبع جميع دوال العمليات الحسابية في Cloud Firestore السلوكيات التالية:
- يتم تقييمها على أنّها
NULLإذا كانت أيّ من مَعلمات الإدخالNULL. - يتم تقييمها على أنّها
NaNإذا كانت أي من الوسيطاتNaN. - يؤدي إلى حدوث خطأ في حال حدوث تجاوز الحد الأقصى أو الأدنى.
بالإضافة إلى ذلك، عندما تأخذ دالة حسابية وسيطات رقمية متعددة من أنواع مختلفة (على سبيل المثال: add(5.0, 6))، تحوّل Cloud Firestore الوسيطات ضمنيًا إلى أوسع نوع إدخال. في حال توفير مدخلات INT32 فقط، سيكون نوع القيمة المعروضة INT64.
| الاسم | الوصف |
ABS
|
لعرض القيمة المطلقة لـ number
|
ADD
|
لعرض قيمة x + y
|
SUBTRACT
|
لعرض قيمة x - y
|
MULTIPLY
|
لعرض قيمة x * y
|
DIVIDE
|
لعرض قيمة x / y
|
MOD
|
لعرض ما تبقى من قسمة x / y
|
CEIL
|
تعرض هذه الدالة الحد الأدنى لعدد number
|
FLOOR
|
تعرض هذه الدالة أصغر عدد صحيح أكبر من أو يساوي number
|
ROUND
|
تقريب number إلى places من المنازل العشرية
|
POW
|
لعرض قيمة base^exponent
|
SQRT
|
لعرض الجذر التربيعي لـ number
|
EXP
|
لعرض عدد أويلر مرفوعًا إلى الأس exponent
|
LN
|
تعرض هذه الدالة اللوغاريتم الطبيعي لعدد number
|
LOG
|
لعرض لوغاريتم number
|
LOG10
|
لعرض لوغاريتم number للأساس 10
|
RAND
|
تعرض عددًا عشريًا عشوائيًا زائفًا |
ABS
البنية:
abs[N <: INT32 | INT64 | FLOAT64](number: N) -> N
الوصف:
تعرض هذه الدالة القيمة المطلقة للعدد number.
- يتم عرض خطأ عندما تتجاوز الدالة قيمة
INT32أوINT64.
أمثلة:
| رقم | abs(number) |
|---|---|
| 10 | 10 |
| -10 | 10 |
| 10L | 10L |
| -0.0 | 0.0 |
| 10.5 | 10.5 |
| -10.5 | 10.5 |
| -231 | [error] |
| -263 | [error] |
إضافة
البنية:
add[N <: INT32 | INT64 | FLOAT64](x: N, y: N) -> N
الوصف:
تعرض هذه الدالة قيمة x + y.
أمثلة:
| x | y | add(x, y) |
|---|---|---|
| 20 | 3 | 23 |
| 10.0 | 1 | 11.0 |
| 22.5 | 2.0 | 24.5 |
| INT64.MAX | 1 | [error] |
| INT64.MIN | -1 | [error] |
Web
const result = await execute(db.pipeline() .collection("books") .select(field("soldBooks").add(field("unsoldBooks")).as("totalBooks")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("soldBooks").add(Field("unsoldBooks")).as("totalBooks")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(Expression.add(field("soldBooks"), field("unsoldBooks")).alias("totalBooks")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(Expression.add(field("soldBooks"), field("unsoldBooks")).alias("totalBooks")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("soldBooks").add(Field.of("unsoldBooks")).as_("totalBooks")) .execute() )
SUBTRACT
البنية:
subtract[N <: INT32 | INT64 | FLOAT64](x: N, y: N) -> N
الوصف:
تعرض هذه الدالة قيمة x - y.
أمثلة:
| x | y | subtract(x, y) |
|---|---|---|
| 20 | 3 | 17 |
| 10.0 | 1 | 9.0 |
| 22.5 | 2.0 | 20.5 |
| INT64.MAX | -1 | [error] |
| INT64.MIN | 1 | [error] |
Web
const storeCredit = 7; const result = await execute(db.pipeline() .collection("books") .select(field("price").subtract(constant(storeCredit)).as("totalCost")) );
Swift
let storeCredit = 7 let result = try await db.pipeline() .collection("books") .select([Field("price").subtract(Constant(storeCredit)).as("totalCost")]) .execute()
Kotlin
val storeCredit = 7 val result = db.pipeline() .collection("books") .select(Expression.subtract(field("price"), storeCredit).alias("totalCost")) .execute()
Java
int storeCredit = 7; Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(Expression.subtract(field("price"), storeCredit).alias("totalCost")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field store_credit = 7 result = ( client.pipeline() .collection("books") .select(Field.of("price").subtract(store_credit).as_("totalCost")) .execute() )
MULTIPLY
البنية:
multiply[N <: INT32 | INT64 | FLOAT64](x: N, y: N) -> N
الوصف:
تعرض هذه الدالة قيمة x * y.
أمثلة:
| x | y | multiply(x, y) |
|---|---|---|
| 20 | 3 | 60 |
| 10.0 | 1 | 10.0 |
| 22.5 | 2.0 | 45.0 |
| INT64.MAX | 2 | [error] |
| INT64.MIN | 2 | [error] |
| FLOAT64.MAX | FLOAT64.MAX | +inf |
Web
const result = await execute(db.pipeline() .collection("books") .select(field("price").multiply(field("soldBooks")).as("revenue")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("price").multiply(Field("soldBooks")).as("revenue")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(Expression.multiply(field("price"), field("soldBooks")).alias("revenue")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(Expression.multiply(field("price"), field("soldBooks")).alias("revenue")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("price").multiply(Field.of("soldBooks")).as_("revenue")) .execute() )
DIVIDE
البنية:
divide[N <: INT32 | INT64 | FLOAT64](x: N, y: N) -> N
الوصف:
تعرض هذه الدالة قيمة x / y. يتم اقتطاع القسمة على عدد صحيح.
أمثلة:
| x | y | divide(x, y) |
|---|---|---|
| 20 | 3 | 6 |
| 10.0 | 3 | 3.333... |
| 22.5 | 2 | 11.25 |
| 10 | 0 | [error] |
| 1.0 | 0.0 | +inf |
| -1.0 | 0.0 | -inf |
Web
const result = await execute(db.pipeline() .collection("books") .select(field("ratings").divide(field("soldBooks")).as("reviewRate")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("ratings").divide(Field("soldBooks")).as("reviewRate")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(Expression.divide(field("ratings"), field("soldBooks")).alias("reviewRate")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(Expression.divide(field("ratings"), field("soldBooks")).alias("reviewRate")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("ratings").divide(Field.of("soldBooks")).as_("reviewRate")) .execute() )
تعديل
البنية:
mod[N <: INT32 | INT64 | FLOAT64](x: N, y: N) -> N
الوصف:
تعرض هذه الدالة باقي القسمة x / y.
- يتم عرض الخطأ
errorعندما تكون قيمةyصفرًا لأنواع الأعداد الصحيحة (INT64). - تعرض الدالة
NaNعندما تكون قيمةyصفرًا لأنواع الأعداد العشرية (FLOAT64).
أمثلة:
| x | y | mod(x, y) |
|---|---|---|
| 20 | 3 | 2 |
| -10 | 3 | -1 |
| 10 | -3 | 1 |
| -10 | -3 | -1 |
| 10 | 1 | 0 |
| 22.5 | 2 | 0.5 |
| 22.5 | 0.0 | NaN |
| 25 | 0 | [error] |
Web
const displayCapacity = 1000; const result = await execute(db.pipeline() .collection("books") .select(field("unsoldBooks").mod(constant(displayCapacity)).as("warehousedBooks")) );
Swift
let displayCapacity = 1000 let result = try await db.pipeline() .collection("books") .select([Field("unsoldBooks").mod(Constant(displayCapacity)).as("warehousedBooks")]) .execute()
Kotlin
val displayCapacity = 1000 val result = db.pipeline() .collection("books") .select(Expression.mod(field("unsoldBooks"), displayCapacity).alias("warehousedBooks")) .execute()
Java
int displayCapacity = 1000; Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(Expression.mod(field("unsoldBooks"), displayCapacity).alias("warehousedBooks")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field display_capacity = 1000 result = ( client.pipeline() .collection("books") .select(Field.of("unsoldBooks").mod(display_capacity).as_("warehousedBooks")) .execute() )
CEIL
البنية:
ceil[N <: INT32 | INT64 | FLOAT64](number: N) -> N
الوصف:
تعرِض هذه الدالة أصغر قيمة عدد صحيح لا تقلّ عن number.
أمثلة:
| رقم | ceil(number) |
|---|---|
| 20 | 20 |
| 10 | 10 |
| 0 | 0 |
| 24L | 24L |
| -0.4 | -0.0 |
| 0.4 | 1.0 |
| 22.5 | 23.0 |
+inf |
+inf |
-inf |
-inf |
Web
const booksPerShelf = 100; const result = await execute(db.pipeline() .collection("books") .select( field("unsoldBooks").divide(constant(booksPerShelf)).ceil().as("requiredShelves") ) );
Swift
let booksPerShelf = 100 let result = try await db.pipeline() .collection("books") .select([ Field("unsoldBooks").divide(Constant(booksPerShelf)).ceil().as("requiredShelves") ]) .execute()
Kotlin
val booksPerShelf = 100 val result = db.pipeline() .collection("books") .select( Expression.divide(field("unsoldBooks"), booksPerShelf).ceil().alias("requiredShelves") ) .execute()
Java
int booksPerShelf = 100; Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( Expression.divide(field("unsoldBooks"), booksPerShelf).ceil().alias("requiredShelves") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field books_per_shelf = 100 result = ( client.pipeline() .collection("books") .select( Field.of("unsoldBooks") .divide(books_per_shelf) .ceil() .as_("requiredShelves") ) .execute() )
FLOOR
البنية:
floor[N <: INT32 | INT64 | FLOAT64](number: N) -> N
الوصف:
تعرض أكبر قيمة عدد صحيح لا تتجاوز number.
أمثلة:
| رقم | floor(number) |
|---|---|
| 20 | 20 |
| 10 | 10 |
| 0 | 0 |
| 2147483648 | 2147483648 |
| -0.4 | -1.0 |
| 0.4 | 0.0 |
| 22.5 | 22.0 |
+inf |
+inf |
-inf |
-inf |
Web
const result = await execute(db.pipeline() .collection("books") .addFields( field("wordCount").divide(field("pages")).floor().as("wordsPerPage") ) );
Swift
let result = try await db.pipeline() .collection("books") .addFields([ Field("wordCount").divide(Field("pages")).floor().as("wordsPerPage") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .addFields( Expression.divide(field("wordCount"), field("pages")).floor().alias("wordsPerPage") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .addFields( Expression.divide(field("wordCount"), field("pages")).floor().alias("wordsPerPage") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .add_fields( Field.of("wordCount").divide(Field.of("pages")).floor().as_("wordsPerPage") ) .execute() )
ROUND
البنية:
round[N <: INT32 | INT64 | FLOAT64 | DECIMAL128](number: N) -> N
round[N <: INT32 | INT64 | FLOAT64 | DECIMAL128](number: N, places: INT64) -> N
الوصف:
تقرِّب places أرقامًا من number. يتم تقريب الأرقام من يمين الفاصلة العشرية إذا كانت places موجبة، ومن يسار الفاصلة العشرية إذا كانت سالبة.
- إذا تم توفير
numberفقط، يتم التقريب إلى أقرب قيمة صحيحة. - يتم التقريب بعيدًا عن الصفر في حالات المنتصف.
- يتم عرض الخطأ
errorإذا أدى التقريب باستخدام قيمةplacesسالبة إلى حدوث تجاوز سعة.
أمثلة:
| رقم | أماكن | round(number, places) |
|---|---|---|
| 15.5 | 0 | 16.0 |
| -15.5 | 0 | -16.0 |
| 15 | 1 | 15 |
| 15 | 0 | 15 |
| 15 | -1 | 20 |
| 15 | -2 | 0 |
| 15.48924 | 1 | 15.5 |
| 231-1 | -1 | [error] |
| 263-1L | -1 | [error] |
Web
const result = await execute(db.pipeline() .collection("books") .select(field("soldBooks").multiply(field("price")).round().as("partialRevenue")) .aggregate(field("partialRevenue").sum().as("totalRevenue")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("soldBooks").multiply(Field("price")).round().as("partialRevenue")]) .aggregate([Field("partialRevenue").sum().as("totalRevenue")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(Expression.multiply(field("soldBooks"), field("price")).round().alias("partialRevenue")) .aggregate(AggregateFunction.sum("partialRevenue").alias("totalRevenue")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(Expression.multiply(field("soldBooks"), field("price")).round().alias("partialRevenue")) .aggregate(AggregateFunction.sum("partialRevenue").alias("totalRevenue")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select( Field.of("soldBooks") .multiply(Field.of("price")) .round() .as_("partialRevenue") ) .aggregate(Field.of("partialRevenue").sum().as_("totalRevenue")) .execute() )
POW
البنية:
pow(base: FLOAT64, exponent: FLOAT64) -> FLOAT64
الوصف:
لعرض القيمة base مرفوعة إلى الأس exponent.
يتم عرض خطأ إذا كانت
base <= 0وexponentسالبة.بالنسبة إلى أي
exponent، تكون قيمةpow(1, exponent)هي 1.بالنسبة إلى أي
base، تكون قيمةpow(base, 0)هي 1.
أمثلة:
| قاعدة | أساس اللوغاريتم الطبيعي | pow(base, exponent) |
|---|---|---|
| 2 | 3 | 8.0 |
| 2 | -3 | 0.125 |
+inf |
0 | 1.0 |
| 1 | +inf |
1.0 |
| -1 | 0.5 | [error] |
| 0 | -1 | [error] |
Web
const googleplex = { latitude: 37.4221, longitude: 122.0853 }; const result = await execute(db.pipeline() .collection("cities") .addFields( field("lat").subtract(constant(googleplex.latitude)) .multiply(111 /* km per degree */) .pow(2) .as("latitudeDifference"), field("lng").subtract(constant(googleplex.longitude)) .multiply(111 /* km per degree */) .pow(2) .as("longitudeDifference") ) .select( field("latitudeDifference").add(field("longitudeDifference")).sqrt() // Inaccurate for large distances or close to poles .as("approximateDistanceToGoogle") ) );
Swift
let googleplex = CLLocation(latitude: 37.4221, longitude: 122.0853) let result = try await db.pipeline() .collection("cities") .addFields([ Field("lat").subtract(Constant(googleplex.coordinate.latitude)) .multiply(111 /* km per degree */) .pow(2) .as("latitudeDifference"), Field("lng").subtract(Constant(googleplex.coordinate.latitude)) .multiply(111 /* km per degree */) .pow(2) .as("longitudeDifference") ]) .select([ Field("latitudeDifference").add(Field("longitudeDifference")).sqrt() // Inaccurate for large distances or close to poles .as("approximateDistanceToGoogle") ]) .execute()
Kotlin
val googleplex = GeoPoint(37.4221, -122.0853) val result = db.pipeline() .collection("cities") .addFields( field("lat").subtract(googleplex.latitude) .multiply(111 /* km per degree */) .pow(2) .alias("latitudeDifference"), field("lng").subtract(googleplex.longitude) .multiply(111 /* km per degree */) .pow(2) .alias("longitudeDifference") ) .select( field("latitudeDifference").add(field("longitudeDifference")).sqrt() // Inaccurate for large distances or close to poles .alias("approximateDistanceToGoogle") ) .execute()
Java
GeoPoint googleplex = new GeoPoint(37.4221, -122.0853); Task<Pipeline.Snapshot> result = db.pipeline() .collection("cities") .addFields( field("lat").subtract(googleplex.getLatitude()) .multiply(111 /* km per degree */) .pow(2) .alias("latitudeDifference"), field("lng").subtract(googleplex.getLongitude()) .multiply(111 /* km per degree */) .pow(2) .alias("longitudeDifference") ) .select( field("latitudeDifference").add(field("longitudeDifference")).sqrt() // Inaccurate for large distances or close to poles .alias("approximateDistanceToGoogle") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field googleplexLat = 37.4221 googleplexLng = -122.0853 result = ( client.pipeline() .collection("cities") .add_fields( Field.of("lat") .subtract(googleplexLat) .multiply(111) # km per degree .pow(2) .as_("latitudeDifference"), Field.of("lng") .subtract(googleplexLng) .multiply(111) # km per degree .pow(2) .as_("longitudeDifference"), ) .select( Field.of("latitudeDifference") .add(Field.of("longitudeDifference")) .sqrt() # Inaccurate for large distances or close to poles .as_("approximateDistanceToGoogle") ) .execute() )
SQRT
البنية:
sqrt[N <: FLOAT64 | DECIMAL128](number: N) -> N
الوصف:
تعرض هذه الدالة الجذر التربيعي لـ number.
- يتم عرض الخطأ
errorإذا كانت قيمةnumberسالبة.
أمثلة:
| رقم | sqrt(number) |
|---|---|
| 25 | 5.0 |
| 12.002 | 3.464... |
| 0.0 | 0.0 |
NaN |
NaN |
+inf |
+inf |
-inf |
[error] |
x < 0 |
[error] |
Web
const googleplex = { latitude: 37.4221, longitude: 122.0853 }; const result = await execute(db.pipeline() .collection("cities") .addFields( field("lat").subtract(constant(googleplex.latitude)) .multiply(111 /* km per degree */) .pow(2) .as("latitudeDifference"), field("lng").subtract(constant(googleplex.longitude)) .multiply(111 /* km per degree */) .pow(2) .as("longitudeDifference") ) .select( field("latitudeDifference").add(field("longitudeDifference")).sqrt() // Inaccurate for large distances or close to poles .as("approximateDistanceToGoogle") ) );
Swift
let googleplex = CLLocation(latitude: 37.4221, longitude: 122.0853) let result = try await db.pipeline() .collection("cities") .addFields([ Field("lat").subtract(Constant(googleplex.coordinate.latitude)) .multiply(111 /* km per degree */) .pow(2) .as("latitudeDifference"), Field("lng").subtract(Constant(googleplex.coordinate.latitude)) .multiply(111 /* km per degree */) .pow(2) .as("longitudeDifference") ]) .select([ Field("latitudeDifference").add(Field("longitudeDifference")).sqrt() // Inaccurate for large distances or close to poles .as("approximateDistanceToGoogle") ]) .execute()
Kotlin
val googleplex = GeoPoint(37.4221, -122.0853) val result = db.pipeline() .collection("cities") .addFields( field("lat").subtract(googleplex.latitude) .multiply(111 /* km per degree */) .pow(2) .alias("latitudeDifference"), field("lng").subtract(googleplex.longitude) .multiply(111 /* km per degree */) .pow(2) .alias("longitudeDifference") ) .select( field("latitudeDifference").add(field("longitudeDifference")).sqrt() // Inaccurate for large distances or close to poles .alias("approximateDistanceToGoogle") ) .execute()
Java
GeoPoint googleplex = new GeoPoint(37.4221, -122.0853); Task<Pipeline.Snapshot> result = db.pipeline() .collection("cities") .addFields( field("lat").subtract(googleplex.getLatitude()) .multiply(111 /* km per degree */) .pow(2) .alias("latitudeDifference"), field("lng").subtract(googleplex.getLongitude()) .multiply(111 /* km per degree */) .pow(2) .alias("longitudeDifference") ) .select( field("latitudeDifference").add(field("longitudeDifference")).sqrt() // Inaccurate for large distances or close to poles .alias("approximateDistanceToGoogle") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field googleplexLat = 37.4221 googleplexLng = -122.0853 result = ( client.pipeline() .collection("cities") .add_fields( Field.of("lat") .subtract(googleplexLat) .multiply(111) # km per degree .pow(2) .as_("latitudeDifference"), Field.of("lng") .subtract(googleplexLng) .multiply(111) # km per degree .pow(2) .as_("longitudeDifference"), ) .select( Field.of("latitudeDifference") .add(Field.of("longitudeDifference")) .sqrt() # Inaccurate for large distances or close to poles .as_("approximateDistanceToGoogle") ) .execute() )
EXP
البنية:
exp(exponent: FLOAT64) -> FLOAT64
الوصف:
تعرض هذه الدالة قيمة عدد أويلر مرفوعًا إلى الأس exponent، ويُطلق عليها أيضًا اسم الدالة الأسية الطبيعية.
أمثلة:
| أساس اللوغاريتم الطبيعي | exp(exponent) |
|---|---|
| 0.0 | 1.0 |
| 10 | e^10 (FLOAT64) |
+inf |
+inf |
-inf |
0 |
Web
const result = await execute(db.pipeline() .collection("books") .select(field("rating").exp().as("expRating")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("rating").exp().as("expRating")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(field("rating").exp().alias("expRating")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("rating").exp().alias("expRating")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("rating").exp().as_("expRating")) .execute() )
LN
البنية:
ln(number: FLOAT64) -> FLOAT64
الوصف:
تعرض اللوغاريتم الطبيعي للعدد number. هذه الدالة مكافئة للدالة log(number).
أمثلة:
| رقم | ln(number) |
|---|---|
| 1 | 0.0 |
| 2L | 0.693... |
| 1.0 | 0.0 |
e (FLOAT64) |
1.0 |
-inf |
NaN |
+inf |
+inf |
x <= 0 |
[error] |
Web
const result = await execute(db.pipeline() .collection("books") .select(field("rating").ln().as("lnRating")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("rating").ln().as("lnRating")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(field("rating").ln().alias("lnRating")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("rating").ln().alias("lnRating")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("rating").ln().as_("lnRating")) .execute() )
LOG
البنية:
log(number: FLOAT64, base: FLOAT64) -> FLOAT64
log(number: FLOAT64) -> FLOAT64
الوصف:
لعرض لوغاريتم number إلى base.
- في حال توفير
numberفقط، تعرض الدالة اللوغاريتم الأساسي لـnumberإلىbase(وهو مرادف لـln(number)).
أمثلة:
| رقم | قاعدة | log(number, base) |
|---|---|---|
| 100 | 10 | 2.0 |
-inf |
Numeric |
NaN |
Numeric. |
+inf |
NaN |
number <= 0 |
Numeric |
[error] |
Numeric |
base <= 0 |
[error] |
Numeric |
1.0 | [error] |
LOG10
البنية:
log10(x: FLOAT64) -> FLOAT64
الوصف:
تعرض هذه الدالة لوغاريتم العدد number للأساس 10.
أمثلة:
| رقم | log10(number) |
|---|---|
| 100 | 2.0 |
-inf |
NaN |
+inf |
+inf |
x <= 0 |
[error] |
RAND
البنية:
rand() -> FLOAT64
الوصف:
لعرض رقم نقطة عائمة عشوائي زائف، يتم اختياره بشكل منتظم بين 0.0 (شامل) و1.0 (غير شامل).