Go to advanced search

by jahboater
Tue Oct 13, 2020 6:14 pm
Forum: Other projects
Topic: A Birthday Present for Fido
Replies: 381
Views: 15583

Re: A Birthday Present for Fido

Heater wrote:
Tue Oct 13, 2020 6:06 pm
A closure/lambda captures variables outside of itself but within it's scope. A function does not. Consider:
I thought the normal scope rules apply for nested functions, at least they do in C. Maybe its different in Rust.
by jahboater
Tue Oct 13, 2020 5:13 pm
Forum: C/C++
Topic: questions to libs having a .h file and a .c file
Replies: 48
Views: 1676

Re: questions to libs having a .h file and a .c file

Alas, there are some inconveniences to this approach. For instance, I read that if your code is in single compilation unit, GCC can optimize your code better by 10-15% (CITATION NEEDED, but still conceivable). Do you mean this? -fwhole-program Assume that the current compilation unit represents the...
by jahboater
Tue Oct 13, 2020 5:05 pm
Forum: Troubleshooting
Topic: Pi0W reaching 140°F
Replies: 4
Views: 148

Re: Pi0W reaching 140°F

Also use:

Code: Select all

vcgencmd get_throttled
if it returns anything other than 0x0 its likely throttled (now, or since the last boot) due to over temperature or under voltage.
As JamesH said, very unlikely on a Pi Zero.
by jahboater
Tue Oct 13, 2020 1:30 pm
Forum: Beginners
Topic: In DOS you can use the ESC to clear the command line.
Replies: 7
Views: 254

Re: In DOS you can use the ESC to clear the command line.

This is all GNU readline stuff (the library used for reading text lines from the keyboard) It is very powerful and can do vi or emac's style editing. There is a file ~/.inputrc (or /etc/inputrc) that can configure it. see: man readline for all the details. Near the end of the man page is a full list...
by jahboater
Tue Oct 13, 2020 1:02 pm
Forum: Beginners
Topic: How to download AND extract a .img.xz file?
Replies: 15
Views: 489

Re: How to download AND extract a .img.xz file?

I'm pretty sure that a simple '>' would do it one bit at a time. Its writes with a block size of 8KB (probably BUFSIZ). But likely the speed is limited by the decompress time, as the writes will go straight into memory (the disk cache). Sync must be used afterwards. You can see the I/O reads and wr...
by jahboater
Tue Oct 13, 2020 9:49 am
Forum: Other projects
Topic: A Birthday Present for Fido
Replies: 381
Views: 15583

Re: A Birthday Present for Fido

Compilers can do all kind of "evil hackery" under the hood. That's rather a different thing to the surface syntax and semantics that is the language itself. Yes of course. Language defined multiple entry points always count as evil in my book. Imagine the problems the linker has. There is also the ...
by jahboater
Tue Oct 13, 2020 8:39 am
Forum: Other projects
Topic: A Birthday Present for Fido
Replies: 381
Views: 15583

Re: A Birthday Present for Fido

coroutines were always implemented in languages like B and C by using longjmp(). A decent compiler might be said to should implement multiple entry points (sort of!) by "partial inlining". That is, it will inline only that part of the function which is actually used. It only works when it can deduce...
by jahboater
Tue Oct 13, 2020 8:16 am
Forum: Beginners
Topic: Terminal v shell from Python RESOLVED
Replies: 3
Views: 164

Re: Terminal v shell from Python

Shelling out from Python via os.system takes me to a screen much like terminal. What is/are the difference(s) if any? What did you give as the argument to os.system() ??? For example, if I give bash, I just get a normal bash shell:- pi@raspberrypi:~ $ pi@raspberrypi:~ $ pi@raspberrypi:~ $ python3 P...
by jahboater
Mon Oct 12, 2020 10:36 pm
Forum: Beginners
Topic: Is there any executable file that is 100% going to be in /bin?
Replies: 14
Views: 372

Re: Is there any executable file that is 100% going to be in /bin?

kerry_s wrote:
Mon Oct 12, 2020 10:04 pm
why not just do /bin/bash
i figure if it's a bash script & there's no bash your screwed anyways. i've never come across a linux without a bash shell or i don't remember. :D
POSIX mandates that /bin/sh must exist.
by jahboater
Mon Oct 12, 2020 10:31 pm
Forum: Beginners
Topic: How to download AND extract a .img.xz file?
Replies: 15
Views: 489

Re: How to download AND extract a .img.xz file?

Believe it or not, with enough optimization , it can be faster to download an img, extract it, and flash it to a SD card, than to flash a local, pre-extracted .img to a SD Card. Yes I'm sure it can. Its incredibly complicated given: different read/download speeds, decompression speeds, indeterminat...
by jahboater
Mon Oct 12, 2020 10:01 pm
Forum: Beginners
Topic: How to download AND extract a .img.xz file?
Replies: 15
Views: 489

Re: How to download AND extract a .img.xz file?

Additionally, in my script I go a couple steps further by loading the first 100MB of the img into cache first, and also it uses the buffer package to overcome I/O bottlenecks for maximum efficiency. Cool! Sounds like you have thought about it!!! The copy does read/write in a loop. Since we have two...
by jahboater
Mon Oct 12, 2020 9:43 pm
Forum: Beginners
Topic: Is there any executable file that is 100% going to be in /bin?
Replies: 14
Views: 372

Re: Is there any executable file that is 100% going to be in /bin?

No matter what OS, no matter if it has a GUI, no matter if it uses systemd or sysvinit, are there any executable files that are going to exist in 100% of linux releases? Weird question, I know. The reason why I ask is because I need a foolproof way of detecting whether what CPU architecture a given...
by jahboater
Mon Oct 12, 2020 9:40 pm
Forum: Beginners
Topic: How to download AND extract a .img.xz file?
Replies: 15
Views: 489

Re: How to download AND extract a .img.xz file?

I'm glad "xz -d" works!
Just for my interest, why are you using "bs=10M" for the dd command?
The cp command (which is very fast in my tests) uses just 128KB block size (see strace cp ....)
by jahboater
Mon Oct 12, 2020 9:29 pm
Forum: Beginners
Topic: How to download AND extract a .img.xz file?
Replies: 15
Views: 489

Re: How to download AND extract a .img.xz file?

You are using "busybox unzip - -p"
Perhaps it should be changed to "xz -d" or similar.
See "man xz" for details.
by jahboater
Mon Oct 12, 2020 9:24 pm
Forum: Bare metal, Assembly language
Topic: Arm 32 bit Assemply in Raspi OS 64?
Replies: 3
Views: 297

Re: Arm 32 bit Assemply in Raspi OS 64?

Why do you want to do that?
To cross assemble it for a 32-bit platform else where?
I mean, why not assemble on the 32-bit Pi you want to run it on?

"as" is very fast. It is also very fast even on slow computers like a Pi Zero.
I cant see the need to cross assemble.
by jahboater
Mon Oct 12, 2020 10:20 am
Forum: C/C++
Topic: how many significant decimal digits has long double?
Replies: 29
Views: 1008

Re: how many significant decimal digits has long double?

Heater wrote:
Mon Oct 12, 2020 10:12 am
Surely you can install the MPFR library simply by using apt
Cool! You just need to install the -dev packages which are the headers.
Building it from source gets you the latest version though and only takes a few minutes on a Pi4.
by jahboater
Mon Oct 12, 2020 10:16 am
Forum: C/C++
Topic: how many significant decimal digits has long double?
Replies: 29
Views: 1008

Re: how many significant decimal digits has long double?

Its been estimated that the number of photons emitted by all the stars in the universe since the universe began is about 1e84 - which is easily representable in a "double" :) (obviously to low precision - no one has measured it).
Perhaps re-assess if you really, truly, need more than 64-bits?
by jahboater
Mon Oct 12, 2020 10:01 am
Forum: C/C++
Topic: how many significant decimal digits has long double?
Replies: 29
Views: 1008

Re: how many significant decimal digits has long double?

dsyleixa123 wrote:
Mon Oct 12, 2020 9:57 am
:o :shock: :?
that's a bit too sophisticated for my simple skills, tbh :roll:
but thank you very much though!
Well, your only other option is to get a new Pi, install 64-bit Raspbian, and just use long double.
The basic Pi4 2GB model is the same $35 price as your Pi2 was!
by jahboater
Mon Oct 12, 2020 9:52 am
Forum: C/C++
Topic: how many significant decimal digits has long double?
Replies: 29
Views: 1008

Re: how many significant decimal digits has long double?

how would I have to use MPFR or this Decimal128 thing, instead of e.g., long double sum=1.644934008173634739273645337382722502, x, y, lim; lim = (M_PI*M_PI)/6.0 ; // M_PI also by long double! long long n = 3457892; x=(long double)n; sum += 1/( x*x ); y = lim - sum; printf("%20d: %32.30f \n", n, y);...
by jahboater
Mon Oct 12, 2020 8:53 am
Forum: C/C++
Topic: how many significant decimal digits has long double?
Replies: 29
Views: 1008

Re: how many significant decimal digits has long double?

I am presuming that _Decimal128 is not available for 32-bit mode? See: https://en.wikipedia.org/wiki/Decimal128_floating-point_format For interest, see the panel on the right hand side with links to the various floating point formats. The GCC implementation: https://gcc.gnu.org/onlinedocs/gcc/Decima...
by jahboater
Mon Oct 12, 2020 8:42 am
Forum: C/C++
Topic: how many significant decimal digits has long double?
Replies: 29
Views: 1008

Re: how many significant decimal digits has long double?

unfortunately I have just the Pi2 v1.1, and I am only always working with Stretch. OK yes, that is 32-bits only. So MPFR is your best option for C. It is well written, mature, and fast. It provides IEEE 754 semantics, with correct rounding, for arbitrary precision. You could compute Pi to a million...
by jahboater
Mon Oct 12, 2020 8:35 am
Forum: C/C++
Topic: how many significant decimal digits has long double?
Replies: 29
Views: 1008

Re: how many significant decimal digits has long double?

dsyleixa123 wrote:
Mon Oct 12, 2020 8:29 am
no, as stated, double is not precise enough.
Then you have no choice - install 64-bit Raspbian, or install MPFR
by jahboater
Mon Oct 12, 2020 8:26 am
Forum: C/C++
Topic: how many significant decimal digits has long double?
Replies: 29
Views: 1008

Re: how many significant decimal digits has long double?

uuuuh... that's really bad. Why? If you just stick with "double" then everything works really well and is truly portable. Do you really need more precision than double can offer ? Double gives you more precision and range than any hand held calculator. Double is the default floating point size for ...
by jahboater
Mon Oct 12, 2020 8:03 am
Forum: C/C++
Topic: how many significant decimal digits has long double?
Replies: 29
Views: 1008

Re: how many significant decimal digits has long double?

Here is a trivial program to demonstrate DBL_DIG: #include <stdio.h> #include <float.h> #include <math.h> #include <fenv.h> int main( void ) { double x = 3.1415926535897932384626433832795028841971693993751058209749445923078164; printf( "Pi is %.*g\n", DBL_DIG, x ); x = 2.0 / 3.0; printf( "2/3 is %.*...
by jahboater
Mon Oct 12, 2020 7:46 am
Forum: C/C++
Topic: how many significant decimal digits has long double?
Replies: 29
Views: 1008

Re: how many significant decimal digits has long double?

As noted above, in 32-bit mode long double is the same as double, both are 64-bits. If your Pi2 is the newer model, then I think it is OK to run the 64-bit version of Raspbian. In which case long double becomes 128-bits, giving you 33 decimal digits. Another alternative is is to use the MPFR multi-p...

Go to advanced search