cbrt() in swift Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The cbrt() function returns the cube root of a number. It is an inbuilt function in Swift. The cbrt() function in Swift returns the cube root of a number. Using the cbrt() function in Swift, we can calculate the cube root of any natural, decimal, and negative number (perfect and non-perfect cubes). Syntax: // return cube root of number // number can be of any type int, float and double // the return type is same as parameter passed // number passed can be integer, perfect cube root or non-perfect cube root cbrt(number) Parameter: The parameter can be of int, float or double type. Return value: cbrt() function returns the cube root of a number. The datatype of the return value is the same as we pass in the parameter. Examples: Input: 64.00 Output: 4.0 Input: 0.0 Output: 0.0 Input: 9 Output: 2.08008 Below is given program to illustrate the cbrt() function: Swift // Swfit Program to implement cbrt() import Swift import Foundation // Perfect cube root print ("The value of cbrt(64.00) : ", cbrt(64.00)); // whole number print ("The value of cbrt(0.0) : ", cbrt(0.0)); // natural number print ("The value of cbrt(10.00) : ", cbrt(10.00)); // Non-perfect cube root print ("The value of cbrt(9.2) : ", cbrt(9.2)); // Negative number print ("The value of cbrt(-3.7) : ", cbrt(-3.7)); Output:The value of cbrt(64.00) : 4.0The value of cbrt(0.0) : 0.0The value of cbrt(10.00) : 2.1544346900318834The value of cbrt(9.2) : 2.0953791063432945The value of cbrt(-3.7) : -1.5466803737720356... Comment More infoAdvertise with us Next Article Strings in Swift B bug8wdqo Follow Improve Article Tags : Swift Geeks Premier League Geeks Premier League 2023 Similar Reads Closures in Swift In Swift, Closures are known as self-contained blocks of functionality that can be passed around and used inside your code. They are quite similar to blocks in C and Objective-C and to lambdas in other programming languages. Closures can also capture and store references to any constants and variabl 9 min read Swift - Dictionary Swift is a programming language designed to work with Apple's Cocoa and Cocoa Touch frameworks. It is intended to be a modern, safe, and flexible alternative to Objective-C. It is built with the open-source community in mind, and it is actively developed by members of the Swift community. Swift is a 9 min read Swift - For-in Loop The for-in loop in Swift is very similar to for loop in Python. In Python, we write for iteration in range(). Here iteration is just a variable for iteration. In swift, also we write for iteration in range. We have collections like sets, arrays, dictionaries, so we can iterate their items using a fo 6 min read Strings in Swift Swift 4 strings have requested an assortment of characters, for example, "Welcome GeeksforGeeks" and they are addressed by the Swift 4 information type String, which thus addresses an assortment of upsides of Character type. Strings in Swift are Unicode right and region obtuse and are intended to be 8 min read Swift - Subscripts Subscripts are used to access the element members of a collection, sequence, or list in Classes, Structures, and Enumerations. These subscripts are used to store and retrieve the values with the aid of an index. SomeDicitonary[key] is used to access dictionary instances' later member elements, and s 2 min read Swift - Error Handling Error handling is a response to the errors faced during the execution of a function. A function can throw an error when it encounters an error condition, catch it, and respond appropriately. In simple words, we can add an error handler to a function, to respond to it without exiting the code or the 2 min read Like