Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9129959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:51:56+00:00 2026-06-17T07:51:56+00:00

Does F# have a built in cube root function? I know I can use

  • 0

Does F# have a built in cube root function? I know I can use exponentiation to compute cuberoots but it won’t type check in my case since I want to take the cuberoot of a quantity of type float and get a float.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:51:57+00:00Added an answer on June 17, 2026 at 7:51 am

    I don’t think there is a built-in function to calculate the cube root with units of measure (I assume it would be in the primitive operators module where sqrt and others are), so I think the only option is to use exponentiation.

    However, you can use exponentiation without units and wrap the unit-unsafe operation in a function that adds units, so you get function with correct units:

    let cuberoot (f:float<'m^3>) : float<'m> = 
      System.Math.Pow(float f, 1.0/3.0) |> LanguagePrimitives.FloatWithMeasure
    

    Note that F# does not support fractional units so you can write cuberoot (10.0<m^3>) or cuberoot (10.0<m^9>), but if you write cuberoot (10.0<m>) then it will not type-check, because the result would be meters to 1/3 (and that’s a fractional unit).

    This sample is only implementing cuberoot for float. If you wanted to write overloaded function that works with other numeric types (I guess you might need float32) then it gets a bit uglier (so I would not recommend that unless necessary), but you can use a trick with intermediate type with multiple overloads like, for example, in this answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does Actionscript have a built-in function that accepts a number and can return a
Does .NET have some type of built in function that allows filtering on Gridviews?
PHP does not have built-in image editing capability, but many projects use the GD
Does anyone know of any publicly available Question answering applications which have built using
Does jQuery have built in JSON support or must I use a plugin like
Does ActiveRecord have a built-in upsert functionality? I know I could write it myself
Does JavaScript have a built-in function like PHP's addslashes (or addcslashes ) function to
Does GreaseMonkey have something built in so you can store data per-site or per-page?
I've configured MiniProfiler to use the SqlServerStorage. Does MiniProfiler have a built in way
Does python have a built-in function that converts a matrix into row echelon form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.