컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
arrays.index_to_float
arrays.index_to_float(array, index)
설명
배열의 지정된 색인에 있는 요소를 반환합니다. 해당 색인의 요소가 float로 반환됩니다.
색인은 배열에서 요소의 위치를 나타내는 정수 값입니다.
기본적으로 배열의 첫 번째 요소는 색인이 0이고 마지막 요소는 색인이 n-1입니다. 여기서 n은 배열의 크기입니다.
음수 색인 생성을 사용하면 배열 끝을 기준으로 배열 요소에 액세스할 수 있습니다. 예를 들어 색인 -1은 배열의 마지막 요소를 참조하고 색인 -2는 배열의 마지막에서 두 번째 요소를 참조합니다.
매개변수 데이터 유형
ARRAY_STRINGS|ARRAY_INTS|ARRAY_FLOATS
, INT
반환 유형
FLOAT
코드 샘플
예 1
다음 예시에서는 부동 소수점 배열에서 색인 1의 요소를 가져옵니다.
arrays.index_to_float([1.2, 2.1, 3.5, 4.6], 1) // 2.1
예 2
다음 예시에서는 부동 소수점 배열에서 색인 -1의 요소를 가져옵니다.
arrays.index_to_float([1.2, 2.1, 3.5, 4.6], 0-1) // 4.6
예시 3
다음 예시에서는 배열 크기보다 큰 색인의 요소를 가져옵니다.
arrays.index_to_float([1.2, 2.1, 3.5, 4.6], 6) // 0.0
예 4
다음 예시에서는 빈 배열에서 요소를 가져옵니다.
arrays.index_to_float([], 0) // 0.0
예시 5
다음 예시에서는 문자열 배열에서 색인 1의 요소를 가져옵니다.
arrays.index_to_float(["1.2", "3.3", "2.4"], 1) // 3.3
예시 6
다음 예시에서는 정수 배열에서 색인 2의 요소를 가져옵니다.
arrays.index_to_float([1, 3, 2], 2) // 2.0
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-29(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-29(UTC)"],[[["\u003cp\u003e\u003ccode\u003earrays.index_to_float\u003c/code\u003e retrieves an element from an array at a specified index and returns it as a float.\u003c/p\u003e\n"],["\u003cp\u003eThe function supports positive and negative indexing, where negative indices count backward from the end of the array.\u003c/p\u003e\n"],["\u003cp\u003eIt can handle arrays of strings, integers, or floats, and converts the element at the index to a float.\u003c/p\u003e\n"],["\u003cp\u003eIf the index is out of bounds or the array is empty, \u003ccode\u003earrays.index_to_float\u003c/code\u003e returns 0.0.\u003c/p\u003e\n"],["\u003cp\u003eThe function is available in both Rules and Search functionalities.\u003c/p\u003e\n"]]],[],null,["### arrays.index_to_float\n\nSupported in: \n[Rules](/chronicle/docs/detection/default-rules) [Search](/chronicle/docs/investigation/udm-search) \n\n arrays.index_to_float(array, index)\n\n#### Description\n\nReturns the element at the given index of an array. The element at that index is returned as a float.\n\nThe index is an integer value which represents the position of an element in the array.\nBy default, the first element of an array has an index of 0, and the last element has an index of n-1, where n is the size of the array.\nNegative indexing allows accessing array elements relative to the end of the array. For example, an index of -1 refers to the last element in the array and an index of -2 refers to the second to last element in the array.\n\n#### Param data types\n\n`ARRAY_STRINGS|ARRAY_INTS|ARRAY_FLOATS`, `INT`\n\n#### Return type\n\n`FLOAT`\n\n#### Code samples\n\n##### Example 1\n\nThe following example fetches an element at index 1 from an array of floats. \n\n arrays.index_to_float([1.2, 2.1, 3.5, 4.6], 1) // 2.1\n\n##### Example 2\n\nThe following example fetches an element at index -1 from an array of floats. \n\n arrays.index_to_float([1.2, 2.1, 3.5, 4.6], 0-1) // 4.6\n\n##### Example 3\n\nThe following example fetches an element for an index greater than the size of the array. \n\n arrays.index_to_float([1.2, 2.1, 3.5, 4.6], 6) // 0.0\n\n##### Example 4\n\nThe following example fetches an element from an empty array. \n\n arrays.index_to_float([], 0) // 0.0\n\n##### Example 5\n\nThe following example fetches an element at index 1 from a string array. \n\n arrays.index_to_float([\"1.2\", \"3.3\", \"2.4\"], 1) // 3.3\n\n##### Example 6\n\nThe following example fetches an element at index 2 from an array of integers. \n\n arrays.index_to_float([1, 3, 2], 2) // 2.0"]]