Go to advanced search

by jahboater
Thu Dec 15, 2016 1:04 pm
Forum: General programming discussion
Topic: Making readable modifyable code.
Replies: 309
Views: 63878

Re: Making readable modifyable code.

Interesting ... decimal digits of precision, then it would appear calculations involving the national debt could be performed using JavaScript or maybe even Microsoft Excel. Note, however, that 10 cents is not possible to represent accurately using using any floating point representation. The Intel ...
by jahboater
Thu Dec 15, 2016 12:15 am
Forum: General discussion
Topic: Gigabit Ethernet at this stage?
Replies: 156
Views: 25949

Re: Gigabit Ethernet at this stage?

Data transfer is sending the data as fast as possible. The ping test is useless as it artificially imposes half duplex (send 64k, wait for response of 64k, with turn-around delay. ~* ping -s 64000 -c2 pi PING pi (192.168.0.80) 64000(64028) bytes of data. 64008 bytes from pi (192.168.0.80): icmp_seq...
by jahboater
Wed Dec 14, 2016 9:52 pm
Forum: General discussion
Topic: Gigabit Ethernet at this stage?
Replies: 156
Views: 25949

Re: Gigabit Ethernet at this stage?

That does not test throughput (ie data transfer speed) just ping time. Useless. Its measuring the round trip time for a nearly 64k byte packet - so its moving 128k bytes through the interface in that time (the "-s 64000" is the givaway). Please - what do you call data transfer ? Further, its not in...
by jahboater
Wed Dec 14, 2016 9:05 pm
Forum: General discussion
Topic: Gigabit Ethernet at this stage?
Replies: 156
Views: 25949

Re: Gigabit Ethernet at this stage?

Here are some timings for various Pi's and a C2. The C2 does win here but as you can see its only a tiny bit faster than the Pi3 with a USB ethernet adapter, not enough to notice I think. And the Pi3 is going through two switches, the C2 one. ~* ping -c 10 -s 64000 pi0 // Pi Zero usb ethernet PING p...
by jahboater
Wed Dec 14, 2016 8:31 pm
Forum: General discussion
Topic: Gigabit Ethernet at this stage?
Replies: 156
Views: 25949

Re: Gigabit Ethernet at this stage?

Well I think the best OS for ARM SBC's full stop is Raspbian for various reasons. But for the Odroid-C2, Ubuntu works, and is 64-bit, but its kernel is 3.14 whereas Raspbian is moving towards 4.9 by the looks of it. And look at this: ~* time scp myfile [email protected]: myfile 100% 378KB 378.0KB/s 00:00 real 0...
by jahboater
Wed Dec 14, 2016 6:02 pm
Forum: General discussion
Topic: Gigabit Ethernet at this stage?
Replies: 156
Views: 25949

Re: Gigabit Ethernet at this stage?

The Odroid-C2 is similarly priced to the Pi3 and has GbE directly connected to the SoC giving over 930Mbps speeds. But the community support, decent software, huge availability of add-ons, etc etc that you get with the Pi outweigh the presence of GbE in my book.
by jahboater
Wed Dec 14, 2016 5:55 pm
Forum: General discussion
Topic: Gigabit Ethernet at this stage?
Replies: 156
Views: 25949

Re: Gigabit Ethernet at this stage?

by jahboater
Wed Dec 14, 2016 11:50 am
Forum: General programming discussion
Topic: Making readable modifyable code.
Replies: 309
Views: 63878

Re: Making readable modifyable code.

Intel x87 uses 80 bit float registers doesn't it? However JS sticks to IEEE 754 double-precision format which fits in 64 bits so only 53 bit ints are available in there. Same as C doubles I believe. Yes, the IEEE 754 double-precision format is very widely available, so its good choice for JS. NEON ...
by jahboater
Wed Dec 14, 2016 11:10 am
Forum: General programming discussion
Topic: Making readable modifyable code.
Replies: 309
Views: 63878

Re: Making readable modifyable code.

I did some work with floating point stuff in 8-bit micros waay back (starting with some old code present in the Apple II!) and things like rounding, equality, and cumulative errors were part of the course I did at uni... Wonder if they still teach stuff like that? They didn't when I was at uni. In ...
by jahboater
Wed Dec 14, 2016 11:03 am
Forum: General programming discussion
Topic: Making readable modifyable code.
Replies: 309
Views: 63878

Re: Making readable modifyable code.

In Javascript integers will be represented precisely as long as they can be represented in the 53 bits that fit into a the mantissa of a 64 bit float. (Or is it 52 bits, I forget). As such the equality operator works correctly on integers in JS. So you can compare two floats for equality safely if ...
by jahboater
Wed Dec 14, 2016 8:17 am
Forum: General programming discussion
Topic: Making readable modifyable code.
Replies: 309
Views: 63878

Re: Making readable modifyable code.

Aside: One should never compare floating point values for equality. Even more off topic, but how does JS deal with that? It stores integers in 64-bit floats, but I would be upset if I couldn't safely compare them for equality. My guess is it probably just works and nearbyint(x) == x if they are gen...
by jahboater
Tue Dec 13, 2016 9:56 pm
Forum: General programming discussion
Topic: Making readable modifyable code.
Replies: 309
Views: 63878

Re: Making readable modifyable code.

OK. But who ever said they were integers? You did: 1000000000000000000000000000000 is an integer, 1000000000000000000000000000000.0 is floating point. Same as 2 and 2.0, just because they are large doesn't change the type. Its true in most languages except the really sad ones. It's worse than I tho...
by jahboater
Tue Dec 13, 2016 8:29 pm
Forum: General programming discussion
Topic: Making readable modifyable code.
Replies: 309
Views: 63878

Re: Making readable modifyable code.

What does; Python do when you write: 1000000000000000000000000000000 / 3000000000000000000000000000000 ? Edit: It fails: >>> 1000000000000000000000000000000 / 3000000000000000000000000000000 0L It does not fail, zero is the correct result when dividing these two integers . Your using Python 2 by th...
by jahboater
Tue Dec 13, 2016 6:27 pm
Forum: General programming discussion
Topic: Making readable modifyable code.
Replies: 309
Views: 63878

Re: Making readable modifyable code.

Ah, yes, the "thermo-nuclear" weapon of big integer arithmetic. As far as I can tell your Python code can handle thousands of digits easily. At least until memory runs out. I have no idea if there is any other limitation. I believe Python uses normal integers up to their limit, then silently starts...
by jahboater
Tue Dec 13, 2016 6:21 pm
Forum: General programming discussion
Topic: Making readable modifyable code.
Replies: 309
Views: 63878

Re: Making readable modifyable code.

Again, just for the LOLs, I re-did this in RTB. The C version on a Pi 3 takes one second in my setup - not sure how you got 0.2 there: The RTB version seems quite readable, but again I would prefer at least 4-space indenting. Using the -mcpu=cortex-a7 compiler flag makes a difference in the speed o...
by jahboater
Tue Dec 13, 2016 2:58 pm
Forum: General programming discussion
Topic: Making readable modifyable code.
Replies: 309
Views: 63878

Re: Making readable modifyable code.

From a code readability point of view, I would suggest using at least 4-space indents, standard for loops and at least one comment. I used 4-space indents in C for about 30 years, then some coding standard required 2-space indents - which, surprisingly, I eventually grew to like! #include <stdio.h>...
by jahboater
Tue Dec 13, 2016 2:45 pm
Forum: General programming discussion
Topic: Making readable modifyable code.
Replies: 309
Views: 63878

Re: Making readable modifyable code.

I'm wondering how much of your timing result is the time it takes to load the executable and print the results. Thats a good point, I added some internal timing with the new posix clock_gettime( CLOCK_MONOTONIC, ... ) (which replaces gettimeofday) and it still took: [email protected]:~ $ ./pfn 6 28 49...
by jahboater
Tue Dec 13, 2016 9:25 am
Forum: General programming discussion
Topic: Making readable modifyable code.
Replies: 309
Views: 63878

Re: Making readable modifyable code.

Yes, yes, I know a trivial benchmark doesn't mean much. But it should give a ballpark figure for the speed of the two VM's doing common day to day stuff, integers, simple loops and conditionals . We have 3x C for JS and 30x C for basic, so the differences are large. Also we should be comparing the V...
by jahboater
Tue Dec 13, 2016 8:19 am
Forum: General programming discussion
Topic: Making readable modifyable code.
Replies: 309
Views: 63878

Re: Making readable modifyable code.

No, memoization is nothing to do with dynamic programming. It is a technique that can be used any any programming system. Consider: You write a function to calculate factorials. You know: 5! = 5 * 4 * 3 * 2 * 1, for example. As your program is run perhaps that function is called to calculate the fa...
by jahboater
Mon Dec 12, 2016 5:51 pm
Forum: Troubleshooting
Topic: SSH error during Headless Install
Replies: 19
Views: 7437

Re: SSH error during Headless Install

We're talking about remotely enabling ssh on a Raspberry Pi which has ssh disabled by default. Typing ssh or echo > ssh on a remote computer isn't going to do it. Then neither will "nano ssh" :). But no, you do this on your PC just after you have imaged the card. Mount or automount the SD card's fi...
by jahboater
Mon Dec 12, 2016 5:16 pm
Forum: General programming discussion
Topic: Making readable modifyable code.
Replies: 309
Views: 63878

Re: Making readable modifyable code.

The fact that the maximum value is only 8400511 and that the Pi 3 is running in 32-bit mode makes me wonder why 64-bit integers are used. I wondered that myself, and coded a 32-bit int version when playing with it earlier and found that the | multiply by 3, add 1 | divide by 2 | cycle overflows a 3...
by jahboater
Mon Dec 12, 2016 4:57 pm
Forum: General programming discussion
Topic: Making readable modifyable code.
Replies: 309
Views: 63878

Re: Making readable modifyable code.

Here is a very crude "functionized" version, your steps 1 and 2. From a code readability point of view the function-ized version scores much lower than the original version. In my opinion, if adding function calls makes the code more verbose this reduces readability. Totally agree. All the function...
by jahboater
Mon Dec 12, 2016 3:44 pm
Forum: Troubleshooting
Topic: SSH error during Headless Install
Replies: 19
Views: 7437

Re: SSH error during Headless Install

However, all you have to do is create a blank file called ssh with no extension and no content. nano ssh Once nano or the editor you use opens save the file and exit, in nano this is Ctrl O to save then Ctrl X to exit. You can just do echo >ssh or even just >ssh which should work on the Mac, on Lin...
by jahboater
Mon Dec 12, 2016 3:24 pm
Forum: General programming discussion
Topic: Making readable modifyable code.
Replies: 309
Views: 63878

Re: Making readable modifyable code.

Heater wrote: That is the memoized version. Even the unmemoized version does it in 44.9 seconds, only about 3 times slower than your C code! Not bad.
Yes, that's very fast indeed. Python is way slower than that.
by jahboater
Mon Dec 12, 2016 3:22 pm
Forum: General programming discussion
Topic: Making readable modifyable code.
Replies: 309
Views: 63878

Re: Making readable modifyable code.

Here is a very crude "functionized" version, your steps 1 and 2. Execution time is still 14.8 secs in C because they all get inlined into the single main function again and then optimized as before. #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <inttypes.h> #include <stdbool.h> ...

Go to advanced search