Closed simleb closed 11 years ago
Isn't hard to type this symbol. Even I do have a Input Method, I have to turn to Soft Keyboard to type it. If one really needs this, a simpler alternative would be better. Otherwise, pi / 180
remains a clear way of maintaining codes.
Oh, I didn't realize that. I have a french keyboard (azerty) and ° is just a Shift + ) away!
No one really needs this. It's a detail but it doesn't hurt and is even quite pleasant to use (for french keyboard users at least!).
Same on German keyboards
International version: ComposeKey
+o
+o
-> °
Windows version: Alt
+ NumPad 0, 1, 7, 6
Personally, I like this note which I have used since primary school on paper. Seems it helps people a lot, I fully approve this. Chinese Input Method even has a quite simple workaround for typing this symbol (type du
which is Chinese pronunciation of "degree"), just curious about people using laptop with EN_US keyboards and no NumPad
http://en.wikipedia.org/wiki/%C2%B0#Keyboard_entry
find this...pathetic for laptops
Mathematica defines ° as pi/180 so you can write degrees naturally, like in
Sin[90°]
.
That's not quite true: typing 180° returns 180°, it just acts like pi (at least it does in version 8).
It could be possible to recreate similar behaviour in Julia defining a new type, say AngleDegree
, and have °
be a constant unit of this type, similar to the im
constant for the ComplexPair
type:
https://github.com/JuliaLang/julia/blob/master/base/complex.jl
The downside of this approach is that it would require defining new methods for the mathematical operators (both trigonometric cos
, sin
, as well as +
, *
, etc.)
Well yes, but that's because Mathematica is inherently symbolical, while Julia is not (consider FullSimplify[°/Pi]). I can't see any case in which one would need a separate AngleDegree
type.
I prefer to not do this for a different reason. It imposes a cost on others modifying codes that use such features.
I agree it's probably not worth implementing in Base, but it could be useful to incorporate into a package that allowed for units to be attached to numeric values, similar to F#'s support for units of measure: I've heard from someone in finance that they find it really useful, as they often end up working in weird non-SI units, and that it can help catch conversion and other errors.
Ok. Adding const ° = pi / 180
to your file/module is easy, so we don't need this in base.
Mathematica defines ° as pi/180 so you can write degrees naturally, like in
Sin[90°]
.In julia, it's as easy as typing
° = pi / 180
:I don't see any other clever use of ° so what about making it a constant?