units-of-measurement

Separate number from unit in a string in Python

I have strings containing numbers with their units, e.g. 2GB, 17ft, etc. I would like to separate the number from the unit and create 2 different strings. Sometimes, there is a whitespace between them (e.g. 2 GB) and it's easy to do it using split(' '). When they are together (e.g. 2GB), I would test every character until I find a lette...

How to convert bytes to megabytes

I've seen three ways of doing conversion from bytes to megabytes: megabytes=bytes/1000000 megabytes=bytes/1024/1024 megabytes=bytes/1024/1000 Ok, I think #3 is totally wrong but I have seen it. I think #2 is right, but I am looking for some respected authority (like W3C, ISO, NIST, etc) to clarify which megabyte is a true megabyte. ...

How to easily compute time in Excel

I want to do quick calculations in Excel. I have a cell (A1) with 50:00:00. I do =A1+1 and get 74:00:00. So, I guess 1=24 hours=1 day. However, I try =A1+1:23:45 and get an error. Is there an easy way to add hours to hours in Excel? If not, do you have a better tool? Please don't say something like =A1+1/24+23/24/60+45/24/60/60. ...

Does iPhone have locale values for measurement units? Eg kg, lb and etc?

I've searched the iPhone documentation and on google but have not found any information regarding locale values for preferred measurement units such as kg or lb and etc. Does anyone know if this does exist? Or conversely NOT exist? Thanks ...

Pattern Matching of Units of Measure in F#

This function: let convert (v: float<_>) = match v with | :? float<m> -> v / 0.1<m> | :? float<m/s> -> v / 0.2<m/s> | _ -> failwith "unknown" produces an error The type 'float<'u>' does not have any proper subtypes and cannot be used as the source of a type test or runtime coercion. Is there any way how to pattern match...

JSR 275 - Units, Percent per second

Hi all, I need to represent the unit of Percent per second using the JScience.org's JSR 275 units and measures implementation. I am trying to do to the following: Unit<Dimensionless> PERCENT_PER_SECOND = NonSI.PERCENT.divide(Si.SECOND).asType(Dimensionless.class) but I am getting a ClassCastException when I try to do that. The fo...

SQL Server 2008 Geography .STBuffer() distance measurement units

I'm working with a geographic point using lat/long and need to find other points in our database within a 5 mile radius of that point. However, I can't seem to find out what the "units" are for STBuffer, it doesn't seem to conform to feet, miles, meters, kilometers, etc. The documentation only refers to them as "units", any suggestions? ...

Are there any solutions for translating measurement units on Rails?

I'd like to implement measurement unit preferences in a Ruby on Rails app. For instance, the user should be able to select between displaying distances in miles or in kilometers. And, obviously, not only displaying, but entering values, too. I suppose all values should be stored in one global measurement system to simplify calculations...

C++ boost ublas + units dimension constraints

hello. I am seeking advice on design/general idea on how to force matrix dimension constraints on ublas matrix/vector possibly using boost units. For example, let matrix A have dimensions of time x force (for example) // does not have dimensions, time x force and force x time are not distinguished. matrix<double> A; //something like?...

Unit Conversions! Ghz - ns - MHz - cycles

I am preparing for a units quiz and there are two kinds of conversions that have me stumped. Type one: What is length (in ns) of one cycle on a XXX computer? - In this case, XXX can be some MHz or Ghz, randomly. I am having trouble converting the cyles times. Example: What is length (in ns) of one cycle on a 50 MegaHertz (MHz) comput...

Memory Units, calculating sizes, help!

I am preparing for a quiz in my computer science class, but I am not sure how to find the correct answers. The questions come in 4 varieties, such as-- Assume the following system: Auxiliary memory containing 4 gigabytes, Memory block equivalent to 4 kilobytes, Word size equivalent to 4 bytes. How many words are in a block, expressed...

How to manage measurement units in a PHP web application?

Hi, I am working on a LAMP web application which is managing a lot of data with different measurement units. This php application use a custom MVC framework. We now have customers in different countries and we would like to offer the choice to the customer between metric, imperial or combination. Currently, all the data are saved in in...

F# units of measure conversion based on type

I'm trying to write a unit of measure converter. I have defined two units of measure, KWh and MWh & am trying to write a function to convert between the two that will pattern match on the numeric type. so I could have a float, decimal, int of KWh to convert to MWh. I'm not able to figure out how to correctly branch on type when I don't h...

Using real world units instead of types

I have a project with many calculations involving a lot of real world units : Distance; Temperature; Flow rate; ... This project involves complicated and numerous calculation formulas. That's why I supposed the use of custom types like Temperature, Distance... can be good for code readability. For example: Temperature x = -55.3; Me...