units-of-measurement

Measurement conversion on the fly

Hi All I'd like to ask re: measurement conversion on the fly, here's the detail : Requirement: To display unit measurement with consider setting. Concerns: - Only basic (neutral) unit measurement is going to be stored in database, and it is decided one time. The grid control has direct binding to our business object therefore it has ...

Working with imperial units

I'm toying with an application that is, roughly speaking, a sort of modeler application for the building industry. In the future I'd like it to be possible for the user to use both SI units and imperial. From what I understand, it's customary in the US building industry to use fractions of inches when specifying measurements, eg 3 1/2" -...

Built-in storage unit conversions utilty in Java?

Hi, there doesn't seem to be an existing util class for converting a storage unit from one to another in Java, am I right? Or is there one actually I wasn't aware of? What I was looking for is something like java.util.concurrent.TimeUnit utility. I can implement the equivalent for storage unit by myself, but just thought I would ask f...

Is there a standard pythonic way to treat physical units / quantities in python?

Is there a standard pythonic way to treat physical units / quantities in python? I saw different module-specific solutions from different fields like physics or neuroscience. But I would rather like to use a standard method than "island"-solutions as others should be able to easily read my code. ...

Validate measurements with PHP

I need to validate measurements entered into a form generated by PHP. I intend to compare them to upper and lower control limits and decide if they fail or pass. As a first step, I imagine a PHP function which accepts strings representing engineering measurements and converts them to pure numbers before the comparison. At the moment ...

F# Units of Measure ... Is there an example of TIME?

Is TIME used in F# Units of Measure? ...

F# Ununit - reunit inside a function

This question is closely related to these ones (1, 2, 3) I'm using an external library which doens't (yet) handle units of measure. I want to be able to 'ununit' values before I pass them in, then 'reunit' them when I get the results back. The catch is that I'd like to avoid being forced to declare WHICH units in advance. Example snip...

how to use units along function parameter values in Mathematica

I would like to pass the parameter values in meters or kilometers (both possible) and get the result in meters/second. I've tried to do this in the following example: u = 3.986*10^14 Meter^3/Second^2; v[r_, a_] := Sqrt[u (2/r - 1/a)]; Convert[r, Meter]; Convert[a, Meter]; If I try to use the defined function and conversion: a = 24...

Representation of dimension units in a standardized way.

Suppose you want to write into a database that something is 30 meters long, or 50 feet, or the temperature was 50 kelvin, the speed was 50 kilometers per hour. How would you represent the units ? To clarify, two points: any kind of units, not a predefined, well defined subset of them. my question is more relative to the existence o...

Reusing units of measure across different types

(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 upda...

Unit-safe square roots

I just wondered how it is possible to write a user-defined square root function (sqrt) in a way that it interacts properly with F#'s unit system. What it should be like: let sqrt (x : float<'u ^ 2>) = let x' = x / 1.0<'u ^ 2> // Delete unit (x ** 0.5) * 1.0<'u> // Reassign unit But this is disallowed due to nonzero const...

Has C#/.NET builtin conversion routines for length units?

Has C#/the .NET library builtin routines or constants for converting e. g. millimetres to inches? If so, where can I find them? (I just do not want to produce duplicate code again and again.) ...

Best mysql datatype for grams, milligrams, micrograms and kilojoule

Hello, I'm very dubious about datatype of my database, I need to use different unit of measurements because I have different elements and different scales, and I'm sure about the limits used, because I take them from standard elements, but I'm afraid about the variety. Just consider I work with 100 grams of product and take from it all e...

iPhone Screen Resolution. 160 vs 163 vs. the future

I'm trying to make an app that displays something in real-world units. It's not a ruler app, but it wants that kind of precision. It already looks like the iPhone and iPod touch have different screen resolutions (160 & 163 respectively) I've found this http://stackoverflow.com/questions/610193/calculating-pixel-size-on-an-iphone and th...

F# Unit of Measure, Casting without losing the measure type

Is there built in version of the type casting functions that preserves units and if not how would I make them? So for example with this code how would I cast intWithSecondsMeasure to a float without losing the measure or multiplying by 1.0<s>? [<Measure>] type s let intWithSecondsMeasure = 1<s> let justAFloat = float intWithSecondsMeasu...

Help with Unit Converter

I am developing a unit converter for my semester project. I need some help on the structure of the classes/interfaces/abstract classes. I want some interface or abstract class that can be inherited by classes (DegreesConverter, MassConverter, LenghtConverter). Like maybe interface IUnitConvert<Type>. I will be dealing with units of angle...

SQL Server units question

This may be a really dumb question, but... What units does Geography.STLength return? The official MSDN page doesn't say anything about the units returned, and this blog entry here says STLength() returns a float indicating the length of the instance in units. Yes, that's right, it says it returns it in units. Can anyone shed some ligh...

How do I make a regex match for measurement units?

I'm building a small Java library which has to match units in strings. For example, if I have "300000000 m/s^2", I want it to match against "m" and "s^2". So far, I have tried most imaginable (by me) configurations resembling (I hope it's a good start) "[[a-zA-Z]+[\\^[\\-]?[0-9]+]?]+" To clarify, I need something that will match lett...

Unit Conversion in Python

I'm working on a project that lets users track different data types over time. Part of the base idea is that a user should be able to enter data using any units that they need to. I've been looking at both units: http://pypi.python.org/pypi/units/ and quantities: http://pypi.python.org/pypi/quantities/ However I'm not sure the best w...

What are the advantages of using ems instead of % in CSS?

I understand the advantages of using ems in favor of static measurements like pixels and points, but why do most of the CSS people out there (SO excepted) prefer using ems instead of % values? Thanks! ...