Tiny Core Base > TCB Bugs
tce-size broken output caused by changes in dc CL syntax since BusyBox 1.30
curaga:
The calc one looks good.
jazzbiker:
Hi,Rich!
--- Quote from: Rich on February 13, 2020, 11:45:40 AM ---The only effected files I found were tce-size and filetool.sh.
--- End quote ---
If really only this two files, the trouble is quite small. But if no (and for those like me, who used dc in their scripts) i attach promised patch for BB 1.31.1 dc.c with dc_main() replaced with the dc_main() from BB 1.29.3 and reenabled keywords for arythmetic operations.
Unfortunately, both ways demand rootfs.gz correction (
Rich:
Hi curaga
--- Quote from: curaga on February 13, 2020, 02:01:41 PM ---The calc one looks good.
--- End quote ---
I have another one. It's a variation of a technique I used on an embedded processor that didn't have space for floating point code.
This is the function that does the work:
--- Code: ---Fixed3Div()
{
# divide $1 by $2. Return result to 3 decimal places, no rounding.
printf "%d.%03d\n" $(($1 / $2)) $(((($1 % $2) * 1000) / $2))
}
--- End code ---
The left side of the decimal point comes from the integer divide --> $(($1 / $2))
The fractional part is derived by dividing the remainder separately after multiplying by 1000 --> $(((($1 % $2) * 1000) / $2))
The printf command handles formatting the fractional part with leading zeros and a field width of 3 digits.
If a divisor of 2 Meg or larger is used there is the potential for overflow (sign reversal) of the fractional part. The divisor in
this application is always 1 MEG so it's not an issue.
This version is just as fast as the dc version.
Juanito:
Changes added to tc git - thanks
Santos:
I love frugality. It's what computing should be.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version