I need someone who can do basic Filter-Maths

Issue … I stole a filter from @EricShulman and edited it to this …

<$let tids="[prefix[$:/RandomDog/]]"
	 count={{{ [subfilter<tids>count[]] }}}
	 bytes={{{ [subfilter<tids>] :map[{!!text}length[]] +[sum[]] }}}
>
 <<bytes>> bytes in <<count>> tiddlers
</$let>

It is to monitor import size of Random Dogs (see: Has anyone used the Random Dog Method? - #8 by TiddlyTitch).

Q: HOW do I change the filter to give Megabytes rather than Bytes?

Best, TT

1 Like

Some people define a megabyte (Mb) as 1000 Kb, where a Kb (kilobyte) is 1024 bytes
1Mb = 1000Kb which is 1024x1000 = 1024000 bytes

However, other people say that the proper calculation is
1Mb = 1024Kb which is 1024x1024 =1048576 bytes

If you use this second number, the filter math calculation is:

Mbytes={{{ [subfilter<tids>] :map[{!!text}length[]] +[sum[]divide[1048576]] }}}

-e

an abomination, but one with historical precedent (1.44 meg floppies)

In practice, the modern standards should be at least referenced here for those unaware - that megabyte (MB) is 1000^2 = 1000000 whilst 1024^2 = 1048576 is a mebibyte (MiB) (a kilobyte (kB) is 1000 and 1024 byes is a kibibyte (KiB)

Fight of the century

How many Bits in A Megabyte?
Part #7: @EricShulman v. @nemo

[[Video unavailable in your country]]

I don’t care. 24kb is nothing now.

All I need, for the purpose, is an approximation that on Mb’s there are too many.

I will test & report back.

TT

@EricShulman, It works very well.

Can you help me round it up to two points?

I get …

6.414379119873047 megabytes in 2 tiddlers

All I need is …

6.41 megabytes in 2 tiddlers

This should do the trick:

Mbytes={{{ [subfilter<tids>] :map[{!!text}length[]] +[sum[]divide[1048576]fixed[2]] }}}

Fred

I added that at the end. All is good.

TX

Successful Result … Random Dog reportage …

TT