Discuss Scratch

ihgfedcba
Scratcher
100+ posts

Float override

Allow overriding the default 64-bit float with 16-bit, 32-bit, 80-bit or 128-bit float. This allows to test what happens as the precision decreases or increases.
mlcreater
Scratcher
1000+ posts

Float override

What would this help? Can you give an example? Also, how would this be implemented? A block might be slow, perhaps a setting like Turbo Mode?

← there are 3 sig figs and 0 kumquats





ihgfedcba
Scratcher
100+ posts

Float override

I mean like a dev option, for curiosity and testing.

(removed by moderator – please use a whitelisted image host for posting images on the forums)

Last edited by Za-Chary (Nov. 24, 2019 19:30:40)

45afc4td
Scratcher
100+ posts

Float override

Support. Even expand it with fixed point formats. And, of course, separate blocks for 64-bit integers.

(removed by moderator – please use a whitelisted image host for posting images on the forums)

Of course, with integers, operations will round down. For example ((3)/(2)) is 1, ((-3)/(2)) is -2. To allow fractions while retaining the binary scheme and the overflow scheme, it's possible to use a custom fixed point.

Last edited by Za-Chary (Nov. 24, 2019 19:30:49)

rdococ
Scratcher
500+ posts

Float override

No support. It would be interesting, but confusing for newer Scratchers, and even a lot of “real” programming languages don't have it in an easily accessible way.
evanultra01
Scratcher
100+ posts

Float override

no support, it would be just super strange to see scratch cat going into the deadlands and sometimes that kinda stuff gets laggy and can even crash pc's so i dont think so
45afc4td
Scratcher
100+ posts

Float override

evanultra01 wrote:

no support, it would be just super strange to see scratch cat going into the deadlands and sometimes that kinda stuff gets laggy and can even crash pc's so i dont think so
How does replacing 64-bit floats with 32-bit floats cause lags and crashes?
Flowermanvista
Scratcher
1000+ posts

Float override

I'm not the most experienced programmer out there, but I'm going to say that I'm not sure if this is even possible in JavaScript - AFAIK, JavaScript has one native number type, which is a double float.

Maybe some funky workaround that uses an array of bits as a sort of virtual memory space designated to store a float/int/what-have-you that can be worked with could be made, but that would surely be much slower than native floating point or integer operations, and you would have to be careful to not accidentally convert it back to the native double float. Not “lags and crashes” slow, but noticeably slower. Maybe there's a smarter workaround that can be implemented by only using double floats, but this is all that came to mind.

Add a SPOOKY SKELETON to your project!

The Scratch 3 Project Save Troubleshooter - find out why your project won't save

ST, Please Add A Warning When A Size Limit Is Exceeded

My Dumb Creations - THE BEST ANIMATION | The Windows 98 Experience (made on Windows 98) | nobody cares about Me… | the2000 Reveals His New Profile Picture | Not Dumb Creations - Ten Years
Ctrl+Shift+Down for more…
Do evil kumquats keep eating your signature? Assert your dominance and eat the evil kumquats. Did you know that kumquats are only about the size of an olive?
6d66yh
Scratcher
100+ posts

Float override

Flowermanvista wrote:

I'm not the most experienced programmer out there, but I'm going to say that I'm not sure if this is even possible in JavaScript - AFAIK, JavaScript has one native number type, which is a double float.

Maybe some funky workaround that uses an array of bits as a sort of virtual memory space designated to store a float/int/what-have-you that can be worked with could be made, but that would surely be much slower than native floating point or integer operations, and you would have to be careful to not accidentally convert it back to the native double float. Not “lags and crashes” slow, but noticeably slower. Maybe there's a smarter workaround that can be implemented by only using double floats, but this is all that came to mind.
The developers could put inline assembly in Javascript to make native floating point as well as native integers. As for 128-bit quadruple precision, we could utilise the code from __float128 in gcc.

Last edited by 6d66yh (April 25, 2021 04:57:30)


Integer arithmetic suggestion: https://scratch.mit.edu/discuss/post/5163608/
999qu
Scratcher
55 posts

Float override

if <([10 ^ v] of (number ❪log❫ )) = [Infinity]> then
set [real number v] to (join ([10 ^ v] of ((number ❪log❫ ) mod (1))) (join [e+] ([floor v] of (number ❪log❫ )))
else
set [real number v] to( [10 ^ v] of (number ❪log❫ ))

Last edited by 999qu (July 24, 2022 18:15:25)


define 999qu as a
genius :: #aa00ff

Spunge::operators
//this is Spunge as a block
BlueDerv
Scratcher
33 posts

Float override

999qu wrote:

if <([10 ^ v] of (number ❪log❫ )) = [Infinity]> then
set [real number v] to (join ([10 ^ v] of ((number ❪log❫ ) mod (1))) (join [e+] ([floor v] of (number ❪log❫ )))
else
set [real number v] to( [10 ^ v] of (number ❪log❫ ))
What relation does this have to adding wider floats?
thugatwoary
Scratcher
100+ posts

Float override

whatd be the point of this? it'd also make no sense for new programmers who are using scratch as their first language

evanultra01 wrote:

no support, it would be just super strange to see scratch cat going into the deadlands and sometimes that kinda stuff gets laggy and can even crash pc's so i dont think so
The Scratch stage has “fencing” preventing Scratch Cat from ever reaching distances where visible issues would occur due to precision loss. It also does not cause lag.

BlueDerv wrote:

999qu wrote:

if <([10 ^ v] of (number ❪log❫ )) = [Infinity]> then
set [real number v] to (join ([10 ^ v] of ((number ❪log❫ ) mod (1))) (join [e+] ([floor v] of (number ❪log❫ )))
else
set [real number v] to( [10 ^ v] of (number ❪log❫ ))
What relation does this have to adding wider floats?
It doesn't have any, its a blockspam necro by a 2048 tile fan whose username isn't even an actual power of 2.

6d66yh wrote:

Flowermanvista wrote:

I'm not the most experienced programmer out there, but I'm going to say that I'm not sure if this is even possible in JavaScript - AFAIK, JavaScript has one native number type, which is a double float.

Maybe some funky workaround that uses an array of bits as a sort of virtual memory space designated to store a float/int/what-have-you that can be worked with could be made, but that would surely be much slower than native floating point or integer operations, and you would have to be careful to not accidentally convert it back to the native double float. Not “lags and crashes” slow, but noticeably slower. Maybe there's a smarter workaround that can be implemented by only using double floats, but this is all that came to mind.
The developers could put inline assembly in Javascript to make native floating point as well as native integers. As for 128-bit quadruple precision, we could utilise the code from __float128 in gcc.
“inline assembly in Javascript” please i cant-

Last edited by thugatwoary (July 24, 2022 19:40:47)


can we not just spam “use contact us” all over questions about scratch? it's really not helpful.
George_The_Scratcher
Scratcher
1 post

Float override

I hope there's a 128-bit float by 2024.
SonicFanX123_321
Scratcher
1000+ posts

Float override

6d66yh wrote:

(#9)
>>The developers could put inline assembly in Javascript<<
no, they couldn't. that's not how assembly or javascript (or the internet itself) works ? it's not possible to put assembly into javascript. javascript is meant to be run on the web, which in turn is meant to be able to run on any processor. assembly, on the other hand, has a variant for every processor.

this is my page

I'm not active on scratch anymore, I moved on.

Powered by DjangoBB