{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/corefx/issues/6831","repository_url":"https://api.github.com/repos/dotnet/corefx","labels_url":"https://api.github.com/repos/dotnet/corefx/issues/6831/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/6831/comments","events_url":"https://api.github.com/repos/dotnet/corefx/issues/6831/events","html_url":"https://github.com/dotnet/corefx/issues/6831","id":140250597,"number":6831,"title":"New Magnitude class for System.Numerics","user":{"login":"varocarbas","id":4943723,"avatar_url":"https://avatars.githubusercontent.com/u/4943723?v=3","gravatar_id":"","url":"https://api.github.com/users/varocarbas","html_url":"https://github.com/varocarbas","followers_url":"https://api.github.com/users/varocarbas/followers","following_url":"https://api.github.com/users/varocarbas/following{/other_user}","gists_url":"https://api.github.com/users/varocarbas/gists{/gist_id}","starred_url":"https://api.github.com/users/varocarbas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/varocarbas/subscriptions","organizations_url":"https://api.github.com/users/varocarbas/orgs","repos_url":"https://api.github.com/users/varocarbas/repos","events_url":"https://api.github.com/users/varocarbas/events{/privacy}","received_events_url":"https://api.github.com/users/varocarbas/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/corefx/labels/api-needs-work","name":"api-needs-work","color":"207de5"},{"url":"https://api.github.com/repos/dotnet/corefx/labels/System.Numerics","name":"System.Numerics","color":"d4c5f9"}],"state":"open","locked":false,"assignee":{"login":"mellinoe","id":8918977,"avatar_url":"https://avatars.githubusercontent.com/u/8918977?v=3","gravatar_id":"","url":"https://api.github.com/users/mellinoe","html_url":"https://github.com/mellinoe","followers_url":"https://api.github.com/users/mellinoe/followers","following_url":"https://api.github.com/users/mellinoe/following{/other_user}","gists_url":"https://api.github.com/users/mellinoe/gists{/gist_id}","starred_url":"https://api.github.com/users/mellinoe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mellinoe/subscriptions","organizations_url":"https://api.github.com/users/mellinoe/orgs","repos_url":"https://api.github.com/users/mellinoe/repos","events_url":"https://api.github.com/users/mellinoe/events{/privacy}","received_events_url":"https://api.github.com/users/mellinoe/received_events","type":"User","site_admin":false},"assignees":[{"login":"mellinoe","id":8918977,"avatar_url":"https://avatars.githubusercontent.com/u/8918977?v=3","gravatar_id":"","url":"https://api.github.com/users/mellinoe","html_url":"https://github.com/mellinoe","followers_url":"https://api.github.com/users/mellinoe/followers","following_url":"https://api.github.com/users/mellinoe/following{/other_user}","gists_url":"https://api.github.com/users/mellinoe/gists{/gist_id}","starred_url":"https://api.github.com/users/mellinoe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mellinoe/subscriptions","organizations_url":"https://api.github.com/users/mellinoe/orgs","repos_url":"https://api.github.com/users/mellinoe/repos","events_url":"https://api.github.com/users/mellinoe/events{/privacy}","received_events_url":"https://api.github.com/users/mellinoe/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/dotnet/corefx/milestones/5","html_url":"https://github.com/dotnet/corefx/milestones/Future","labels_url":"https://api.github.com/repos/dotnet/corefx/milestones/5/labels","id":1328080,"number":5,"title":"Future","description":"Milestone tracking the issues triaged for an unspecified future release","creator":{"login":"joshfree","id":1302850,"avatar_url":"https://avatars.githubusercontent.com/u/1302850?v=3","gravatar_id":"","url":"https://api.github.com/users/joshfree","html_url":"https://github.com/joshfree","followers_url":"https://api.github.com/users/joshfree/followers","following_url":"https://api.github.com/users/joshfree/following{/other_user}","gists_url":"https://api.github.com/users/joshfree/gists{/gist_id}","starred_url":"https://api.github.com/users/joshfree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshfree/subscriptions","organizations_url":"https://api.github.com/users/joshfree/orgs","repos_url":"https://api.github.com/users/joshfree/repos","events_url":"https://api.github.com/users/joshfree/events{/privacy}","received_events_url":"https://api.github.com/users/joshfree/received_events","type":"User","site_admin":false},"open_issues":574,"closed_issues":193,"state":"open","created_at":"2015-09-29T00:25:45Z","updated_at":"2016-07-05T15:16:39Z","due_on":null,"closed_at":null},"comments":51,"created_at":"2016-03-11T17:56:49Z","updated_at":"2016-07-05T17:33:56Z","closed_at":null,"body":"Supporting magnitudes (values + units) might be a good complement for the current vector functionalities of `System.Numerics`. It would allow .NET to deal with any Physics-based situation in an intuitive and easy way. What I am proposing here might also be adapted to other not-related-to-Physics requirements, like angles or computing units (e.g., bit/byte).\r\n\r\nThe new `Magnitude` class is expected to be defined in such a way that all the operations and unit conversions might be easily performed. The idea is allowing programmers to interact with values+units as intuitively as they currently do with just values. For example: having 5 m/s and wanting to convert it to in/s or to add it to 3 ft/h.\r\n\r\nRough sketch of what I have in mind:\r\n\r\n```C#\r\npublic class Magnitude\r\n{\r\n    public static Magnitude operator +(Magnitude first, Magnitude second)\r\n    {\r\n        //It is necessary to confirm whether \"type\" & \"measurement\" are compatible and eventually perform all the required conversions.\r\n        return new Magnitude((decimal)first.value + (decimal)second.value, first.measurement.unit.ToString());\r\n    }\r\n\r\n    //Further basic operator overloads.\r\n\r\n    //Other methods performing basic operations among Magnitude instances.\r\n\r\n\r\n    public readonly MagnitudeType type; //The type of the instance has to remain unaltered.\r\n    public object value { get; set; }  //The getter will be defined on account of the \"measurement\" properties.\r\n    public Measurement measurement { get; set; }\r\n\r\n    public Magnitude(decimal value, string unit)\r\n    {\r\n        this.value = value;\r\n\r\n        //The \"unit\" value will be adequately parsed and analysed. \r\n        //The version below is a simplistic version to show the idea.\r\n        if (unit == \"m\")\r\n        {\r\n            this.type = MagnitudeType.Length;\r\n            this.measurement = new Measurement(UnitSystem.InternationalSystem, LengthInternational.Meter);\r\n        }\r\n        else if (unit == \"ft\")\r\n        {\r\n            this.type = MagnitudeType.Length;\r\n            this.measurement = new Measurement(UnitSystem.ImperialSystem, LengthImperial.Foot);\r\n        }\r\n    }\r\n\r\n    //Other overloads accepting different arguments.\r\n}\r\n\r\npublic class Measurement\r\n{\r\n    public UnitSystem system { get; set; }\r\n    public object unit { get; set; }\r\n\r\n    public Measurement(UnitSystem system, object unit)\r\n    {\r\n        this.system = system;\r\n        this.unit = unit;\r\n    }\r\n}\r\n\r\n//Very simplified versions showing how the enums are expected to look like.\r\npublic enum MagnitudeType { Length, Weight }\r\npublic enum UnitSystem { InternationalSystem, ImperialSystem };\r\npublic enum LengthInternational { Millimeter, Centimeter, Meter };\r\npublic enum LengthImperial { Inch, Foot };\r\n\r\n```\r\n\r\nSimple example showing how the aforementioned code is expected to be used:\r\n\r\n```C#\r\nMagnitude var1 = new Magnitude(1.234m, \"m\"); \r\nMagnitude var2 = new Magnitude(5.678m, \"ft\");\r\nMagnitude var3 = var1 + var2;\r\n```\r\n\r\nI can only think of one drawback for the proposed approach: relying on enums in a situation like this (i.e., with many alternatives and classifications) implies hardcoding a relevant amount of different scenarios. In any case, I think that it would be worthy anyway.\r\n\r\nCLARIFICATION (from my previous contributions, I understand that this issue should be evident, but just in case...): I am expecting to take care of the proposed implementation completely by my own and also to deliver a comprehensive-enough first version. The initial lack of detail is exclusively motivated by the fact that I prefer to not spend too much time on this before confirming that the .NET community/team likes it."},"comment":{"url":"https://api.github.com/repos/dotnet/corefx/issues/comments/230546973","html_url":"https://github.com/dotnet/corefx/issues/6831#issuecomment-230546973","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/6831","id":230546973,"user":{"login":"varocarbas","id":4943723,"avatar_url":"https://avatars.githubusercontent.com/u/4943723?v=3","gravatar_id":"","url":"https://api.github.com/users/varocarbas","html_url":"https://github.com/varocarbas","followers_url":"https://api.github.com/users/varocarbas/followers","following_url":"https://api.github.com/users/varocarbas/following{/other_user}","gists_url":"https://api.github.com/users/varocarbas/gists{/gist_id}","starred_url":"https://api.github.com/users/varocarbas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/varocarbas/subscriptions","organizations_url":"https://api.github.com/users/varocarbas/orgs","repos_url":"https://api.github.com/users/varocarbas/repos","events_url":"https://api.github.com/users/varocarbas/events{/privacy}","received_events_url":"https://api.github.com/users/varocarbas/received_events","type":"User","site_admin":false},"created_at":"2016-07-05T17:33:56Z","updated_at":"2016-07-05T17:33:56Z","body":"@milutinovici Additionally, your approach has to do something on these lines too because you are also accounting for a single type/class (mellinoe + others suggestions were assuming to account for as many types of units being considered). You have to implement code to determine what operations are right/wrong."}}
{"actor":{"display_login":"varocarbas"}}