Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upSuggestion: Change the type of (%) to number -> number -> number #4
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
+1 |
imeckler
referenced this issue
Jan 19, 2015
Closed
Native review for imeckler/stage (just needed a modFloat function) #12
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
imeckler
Jan 20, 2015
Contributor
In response to evancz's comment, I don't know about Haskell or SML, but in OCaml the function I have in mind is called mod_float. Do you prefer to make it a separate function instead of just changing to type of (%)?
|
In response to evancz's comment, I don't know about Haskell or SML, but in OCaml the function I have in mind is called |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
imeckler
Feb 19, 2015
Contributor
If you need such a function, here's an elm implementation in the meantime.
modFloat : Float -> Float -> Float
modFloat x m = x - m * toFloat (floor (x/m))|
If you need such a function, here's an elm implementation in the meantime. modFloat : Float -> Float -> Float
modFloat x m = x - m * toFloat (floor (x/m)) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Feb 19, 2015
Member
I have reservations about using the number type too aggressively, so I'd currently be more comfortable with a separate function. I'm used to seeing it called fmod in places like C++. How this is handled in Java and C# and F#?
|
I have reservations about using the |
rehno-lindeque
referenced this issue
Mar 9, 2015
Closed
Change type of toFloat to number -> Float #190
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
alexiamcdonald
Jun 12, 2015
Contributor
@bjz and I ran into this the other day. What's the status of adding an fmod style function to the core library?
This is what we used:
fmod : Float -> Int -> Float
fmod f n =
let integer = floor f
in toFloat (integer % n) + f - toFloat integer|
@bjz and I ran into this the other day. What's the status of adding an This is what we used: fmod : Float -> Int -> Float
fmod f n =
let integer = floor f
in toFloat (integer % n) + f - toFloat integer |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mus0u
commented
Nov 10, 2015
|
I would also love to see an fmod function added. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
alexiamcdonald
May 2, 2016
Contributor
I've made a library for this one function! It uses the native (%) operator though, so it would have to have a module review. Do you think it is worth it for a one-function package, or can we get this in the standard library?
|
I've made a library for this one function! It uses the native |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
JoshuaOSHickman
Jul 26, 2016
Found myself needing this function. Not hard to write, but I was mostly just surprised there wasn't something in Basics for it.
JoshuaOSHickman
commented
Jul 26, 2016
•
|
Found myself needing this function. Not hard to write, but I was mostly just surprised there wasn't something in Basics for it. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Sep 22, 2016
Member
Consolidated all the math related stuff into the #721 meta issue. Follow along there!
|
Consolidated all the math related stuff into the #721 meta issue. Follow along there! |
evancz
closed this
Sep 22, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Mar 21, 2018
Contributor
A version of this function is now in http://package.elm-lang.org/packages/elm-community/basics-extra/2.3.0/Basics-Extra#fmod (by request elm-community/basics-extra#10).
|
A version of this function is now in http://package.elm-lang.org/packages/elm-community/basics-extra/2.3.0/Basics-Extra#fmod (by request elm-community/basics-extra#10). |
imeckler commentedNov 14, 2014
Is there a compelling reason for (%) to have the current restricted type
Int -> Int -> Int? Javascript (%) works as expected for non-integers and I often actually need this operation.