Discuss Scratch
- gtoal
- Scratcher
1000+ posts
the scratch implementation is what it is and is unlikely to be changed. If it doesn't match your expectation of some function then write a custom block that redefines the function the way you want it.
- asivi
- Scratcher
1000+ posts
the scratch implementation is what it is and is unlikely to be changed. If it doesn't match your expectation of some function then write a custom block that redefines the function the way you want it.
Last edited by asivi (Oct. 5, 2017 13:31:00)
- MartinBraendli2
- Scratcher
100+ posts
You want functions that behave like Mathlabs? following the general convention that Mathlabs states. Is it well resolved in my project?
Thanks again.
Regards..
Mathlabs mod(a,b) in scratch is:
((a) mod (b))
Mathslabs rem(a,b) translates to:
(((a) / ([abs v] of (a))) * (([abs v] of (a)) mod ([abs v] of (b))))
I think your script is wrong. You can't do this with floor, because floor rounds to the lower number. To do this with a rounding function, you'd need a function that rounds to the number “closer” to zero.
EDIT: typo
EDIT2: The mathlab documentation for rem and mod give some example Inputs with resulting outputs. You will notice, that none of your scripts produces the same results as rem().
Last edited by MartinBraendli2 (Sept. 26, 2017 01:03:55)
- asivi
- Scratcher
1000+ posts
You want functions that behave like Mathlabs? following the general convention that Mathlabs states. Is it well resolved in my project?
Thanks again.
Regards..
Mathlabs mod(a,b) in scratch is:((a) mod (b))
Mathslabs rem(a,b) translates to:(((a) / ([abs v] of (a))) * (([abs v] of (a)) mod ([abs v] of (b))))
I think your script is wrong. You can't do this with floor, because floor rounds to the lower number. To do this with a rounding function, you'd need a function that rounds to the number “closer” to zero.
EDIT: typo
EDIT2: The mathlab documentation for rem and mod give some example Inputs with resulting outputs. You will notice, that none of your scripts produces the same results as rem().
Thanks a lot for your help
Greets.
Last edited by asivi (Oct. 5, 2017 13:26:40)