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 379115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:51:37+00:00 2026-05-12T14:51:37+00:00

( Yes , still playing with units of measure ) I’ve just started using

  • 0

(Yes, still playing with units of measure)

I’ve just started using units of measure for something other than float for the first time.

After starting off complicated, I discovered that you can re-use units of measure across multiple ‘types’.

[<Measure>] type mm

let a = 1<mm>
let b = 1.<mm>

Now I’m sitting here wondering how to update my existing mm type to reflect this possibility:

[<Measure>]
type mm =
    static member perMetre = 1000.0<mm/m>
    static member fromMetre (v:float<m>) = v * mm.perMetre
    static member toMetre (v:float<mm>) = v / mm.perMetre
    static member lift (v:float) = v * 1.0<mm>

The question: How do I write a function that can convert from mm to m (say) that can handle int<mm> -> int<m> AND float<mm> -> float<m>?

UPDATE

Thanks to Kurt, here’s the new version:

[<Measure>]
type mm =
    static member private perMetreFloat = 1000.0<mm/m>
    static member private perMetreInt = 1000<mm/m>
    [<OverloadIDAttribute("float")>]
    static member fromMetre (v:float<m>) = v * mm.perMetreFloat
    [<OverloadIDAttribute("float")>]
    static member toMetre (v:float<mm>) = v / mm.perMetreFloat
    [<OverloadIDAttribute("float")>]
    static member lift (v:float) = v * 1.0<mm>
    [<OverloadIDAttribute("int")>]
    static member fromMetre (v:int<m>) = v * mm.perMetreInt
    [<OverloadIDAttribute("int")>]
    static member toMetre (v:int<mm>) = v / mm.perMetreInt
    [<OverloadIDAttribute("int")>]
    static member lift (v:int) = v * 1<mm>
  • 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-05-12T14:51:38+00:00Added an answer on May 12, 2026 at 2:51 pm

    Simply overloading works sometimes (if you have an argument):

    [<Measure>]
    type MM =
        static member perMetre = 1000.0<mm/m>
        static member fromMetre (v:float<m>) = v * MM.perMetre
        static member toMetre (v:float<mm>) = v / MM.perMetre
        [<OverloadIDAttribute("0")>]
        static member lift (v:float) = v * 1.0<mm>
        [<OverloadIDAttribute("1")>]
        static member lift (v:int) = v * 1<mm>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Yes, There's More Than One Way To Do It but there must be a
Yes, the problem is with a library I'm using, and no, I cannot modify
Yes, it's a noob question... I have been using Dev-C++ for all my projects
Iam still getting the exception lazyinitializationexception. Yes, i know that it means, that the
I'm writing a web scraper in python, using httplib2 and lxml (yes - I
Yes, I know. The existence of a running copy of SQL Server 6.5 in
...Yes I've seen: Best Resources for Learning JavaFX? but it doesn't really answer the
Yes, there is a similar question here . However, that question doesn't seem to
Yes, I know you could use regular objects as associative arrays in JavaScript, but
Yes we're talking about ASCII codes. My appologies I'm not the Delphi dev here.

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.