microsoft / jacdac

Device and service catalogs for Jacdac.
https://aka.ms/jacdac
Creative Commons Attribution 4.0 International
66 stars 25 forks source link

block range picker does not hangle 0...1 range #244

Closed pelikhan closed 3 years ago

pelikhan commented 3 years ago

Blockly range expects integer. Does not play well with our 0..1 ranges.

mmoskal commented 3 years ago

Maybe % wouldn't be so bad, even in TypeScript.

We could even have a function like - (v | 0) == v ? Math.idiv(v<<16, 100) : v * ((1 << 16)/100) - no floating point ops when no floating point input

pelikhan commented 3 years ago

Yes better. The value in code match the one displayed.


From: Michał Moskal notifications@github.com Sent: Friday, February 12, 2021 5:12:22 PM To: microsoft/jacdac jacdac@noreply.github.com Cc: Peli de Halleux jhalleux@microsoft.com; Author author@noreply.github.com Subject: Re: [microsoft/jacdac] block range picker does not hangle 0...1 range (#244)

Maybe % wouldn't be so bad, even in TypeScript.

We could even have a function like - (v | 0) == v ? Math.idiv(v<<16, 100) : v * ((1 << 16)/100) - no floating point ops when no floating point input

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fjacdac%2Fissues%2F244%23issuecomment-778287939&data=04%7C01%7Cjhalleux%40microsoft.com%7C86b7e5a2991f44ebea8808d8cf70fb63%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637487431450470877%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=9pLamDSy4ApLMawPuwxCCyAMQFF75pUy9%2Bmc7wrRnEY%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAA73QKIP4GQUQM7Y5LVRACLS6VHONANCNFSM4XQUKGKA&data=04%7C01%7Cjhalleux%40microsoft.com%7C86b7e5a2991f44ebea8808d8cf70fb63%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637487431450480871%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=71OgQGHd6BgkGH2WeGGH%2BVhH4lZ0AN6S6TfKYvL4Ieg%3D&reserved=0.

pelikhan commented 3 years ago

@mmoskal do we have % support in jdpack?

mmoskal commented 3 years ago

How would it look like, "u0.16%" ?

pelikhan commented 3 years ago

Note that 0..100% is generally more intuitive than 0...1 for users (specially younger ones who don't understand decimals well)

mmoskal commented 3 years ago

it may be problematic for math (you'll have to divide by 100 every now an then), but I guess it's the price worth paying.

to be clear - we're not changing anything in the services, only in the MakeCode APIs, right?

pelikhan commented 3 years ago

Yeah I will change the code generator of MakeCode to do the conversion


From: Michał Moskal @.> Sent: Friday, March 26, 2021 7:58:42 PM To: microsoft/jacdac @.> Cc: Peli de Halleux @.>; Author @.> Subject: Re: [microsoft/jacdac] block range picker does not hangle 0...1 range (#244)

it may be problematic for math (you'll have to divide by 100 every now an then), but I guess it's the price worth paying.

to be clear - we're not changing anything in the services, only in the MakeCode APIs, right?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fjacdac%2Fissues%2F244%23issuecomment-808446881&data=04%7C01%7Cjhalleux%40microsoft.com%7C526685b5a190463f9cd308d8f0892d21%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637523819254908503%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=UDu%2BKqWs9RvyEi6c%2FiDtu5DBLX5J8tuy2kRaJi4Zt5s%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAA73QKMVQBSIDIGU2VBNT2LTFTKOFANCNFSM4XQUKGKA&data=04%7C01%7Cjhalleux%40microsoft.com%7C526685b5a190463f9cd308d8f0892d21%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637523819254918495%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=tDdjEU7vJIm7uHUw58fwxEYeE4ZcSX8qd6yCTk%2FEefE%3D&reserved=0.

pelikhan commented 3 years ago

Use 0..100 range now.