Bitcoin Forum
April 20, 2018, 05:56:11 AM *
News: Latest stable version of Bitcoin Core: 0.16.0  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: What happen write number like this at code?  (Read 67 times)
wsxdrfv
Jr. Member
*
Online Online

Activity: 98
Merit: 0


View Profile WWW
April 06, 2018, 12:19:04 AM
 #1

So it should be,
nSubsidy >>= (nHeight / 5112000);


then what happen write like
nSubsidy >>= (nHeight / 5,112,000);

?


my BitcoinEssence (BTE) address : EbpxqVRFy2253rXobedjrHGTi2f1KHkxd4
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1524203771
Hero Member
*
Offline Offline

Posts: 1524203771

View Profile Personal Message (Offline)

Ignore
1524203771
Reply with quote  #2

1524203771
Report to moderator
1524203771
Hero Member
*
Offline Offline

Posts: 1524203771

View Profile Personal Message (Offline)

Ignore
1524203771
Reply with quote  #2

1524203771
Report to moderator
1524203771
Hero Member
*
Offline Offline

Posts: 1524203771

View Profile Personal Message (Offline)

Ignore
1524203771
Reply with quote  #2

1524203771
Report to moderator
achow101
Moderator
Legendary
*
Offline Offline

Activity: 1372
Merit: 1272


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


View Profile WWW
April 06, 2018, 01:29:30 AM
 #2

Compilers don't understand human comma separating for numbers. This code should fail to compile.

wsxdrfv
Jr. Member
*
Online Online

Activity: 98
Merit: 0


View Profile WWW
April 06, 2018, 04:05:43 AM
 #3

Compilers don't understand human comma separating for numbers. This code should fail to compile.
compiled was done with just warning sign. Not failed.

As what number program recognize that , (comma) number?

my BitcoinEssence (BTE) address : EbpxqVRFy2253rXobedjrHGTi2f1KHkxd4
Heisenberg_Hunter
Member
**
Offline Offline

Activity: 126
Merit: 57


View Profile
April 06, 2018, 04:16:39 AM
 #4

So if type like,
nSubsidy >>= (nHeight / 5,112,000);
then 5,112,000 become to what number for computer?  
As other members has given out some exact answers to your question, by the way what do you mean by numbers? Do you mean binary numbers Huh Comma operators can give out a varied results based on its usage in the code. At some times, it may even change the meaning of the code.

For instance consider a simple line of code where

a= b, c here in this the compiler reads them as a=b and a=c which will be similar to your case

if you use 5,112,000 instead of 5112000 as it meant to be, the compiler would end up with compiling 5 separately and 112 separately and 000 separately which would change your code. Hence don't try to use comma unless you are clear with them of where to use them.

And for your question about the number which computer reads, if you compile the 5112000, this would be converted to binary which is 10011100000000011000000 and would be given to the computer which reads them and replies.

wsxdrfv
Jr. Member
*
Online Online

Activity: 98
Merit: 0


View Profile WWW
April 06, 2018, 04:25:54 AM
 #5

As what number program recognize that , (comma) number?
May I know what are you clearly speaking about? If you type your question clearly I will edit this and try to give out the answer!  Huh
So if type like,

nSubsidy >>= (nHeight / 5,112,000);

then 5,112,000 become to what number for computer?  

my BitcoinEssence (BTE) address : EbpxqVRFy2253rXobedjrHGTi2f1KHkxd4
achow101
Moderator
Legendary
*
Offline Offline

Activity: 1372
Merit: 1272


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


View Profile WWW
April 06, 2018, 04:58:43 AM
 #6

So if type like,

nSubsidy >>= (nHeight / 5,112,000);

then 5,112,000 become to what number for computer?  
It doesn't become any number. Code is just text to a computer and is completely meaningless until it is compiled. That number will never have meaning to a computer because it will never be compiled into machine code that has meaning to a computer.

HCP
Hero Member
*****
Offline Offline

Activity: 574
Merit: 722

<insert witty quote here>


View Profile
April 06, 2018, 04:58:53 AM
 #7

Depends on the programming/scripting language being used and the compiler...

In all likelihood, the statement: nSubsidy >>= (nHeight / 5,112,000);
Is being interpreted as: nSubsidy >>= ( (nHeight/5), 112, 000);

Ie. the "number" 5,112,000 is effectively being interpreted as three separate numbers... (5, 112 and 000)

Whether or not that is actually a "valid" statement is dependent on the language.

If it is C\C++, then I suspect that it will attempt to bit shift the value of nSubsidy to the right by "0" bits... the end result being that the value of nSubsidy will NOT change at all. But I haven't tested that.

starmyc
Member
**
Online Online

Activity: 84
Merit: 43

Software engineer


View Profile WWW
April 06, 2018, 05:02:52 AM
Merited by achow101 (4), HCP (2), pebwindkraft (1)
 #8

So if type like,

nSubsidy >>= (nHeight / 5,112,000);

then 5,112,000 become to what number for computer?  

I suggest you take a look at the Comma operator page on Wikipedia, as it will explain it better than me:

In the C and C++ programming languages, the comma operator (represented by the token ,) is a binary operator that evaluates its first operand and discards the result, and then evaluates the second operand and returns this value (and type).

Your code will then only do the following:

Code:
nSubsidy >>= 000;

(The first & the 2nd statement are discarded)

You can try it out by yourself:

Code:
$ cat a.c && gcc -Wall -o a a.c && ./a
#include <stdio.h>

int main() {
    int a, b;

    a = (1, 2, 3);
    printf("a == %d\n", a);
}
a.c: In function ‘main’:
a.c:6:11: warning: left-hand operand of comma expression has no effect [-Wunused-value]
     a = (1, 2, 3);
           ^
a.c:6:14: warning: left-hand operand of comma expression has no effect [-Wunused-value]
     a = (1, 2, 3);
              ^
a == 3

A valid usage:

Code:
$ cat a.c && gcc -Wall -o a a.c && ./a
#include <stdio.h>

int main() {
    int a, b;

    b = 1;
    a = (a = b+1, a--, a+1);
    printf("a == %d\n", a);
}
a == 2

The code is executed the following: b = 1; a = b+1 (a will be == 2); a-- (a will be == 1); a+1 will return 2 then this value will be assigned to a. a results as 2.


As you'll see on the wikipedia page, the comma operator has multiple usages.

Software engineer for hire: API, Fullstack dev, Altcoin help & support, ETH contracts, sysadmin... PM me if you need help!
Tip me: 3An9ddmuGr7DsvdUUFJshCidq97E3Re8Eg
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!