| |

VerySource

 Forgot password?
 Register
Search
View: 5185|Reply: 31

How to represent 0 of short type?

[Copy link]

1

Threads

31

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-2-13 23:30:01
| Show all posts |Read mode
I know Long type 0, which can be represented by 0L,
0 of decimal type can be represented by 0m,
So how to represent 0 of short type?

or,
There is a value of type object, and its bits are 0, so how do I know that its bits are 0?
Reply

Use magic Report

0

Threads

32

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-4-13 07:45:01
| Show all posts
There is no similar representation.
Reply

Use magic Report

0

Threads

32

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-4-13 09:15:01
| Show all posts
short has no similar representation.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 Italy

Post time: 2020-4-13 11:00:01
| Show all posts
Why should we emphasize short 0? . . .
Big 0 is good. . . .
Reply

Use magic Report

0

Threads

56

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-4-13 18:00:02
| Show all posts
short is an alias of System.Int16, which means 16 signed integer, directly short a = 0;

another:
"There is a value of type object, and all its bits are 0", which seems to not understand ...
Reply

Use magic Report

0

Threads

38

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-4-14 20:45:01
| Show all posts
Only 5 types of int uint long ulong decimal can participate in arithmetic operations
It only makes sense to specify the constant type, there is no problem of short type constants,
short can be implicitly converted to int automatically
Reply

Use magic Report

0

Threads

38

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-4-14 23:45:01
| Show all posts
// There is a value of type object, its bits are 0, so how do I know that its bits are 0
object is a reference type, there is no saying that every bit is 0
Only after unboxing restores the value type it represents
As for whether a certain bit is 1 or 0, you can use the bit operation&
Reply

Use magic Report

0

Threads

110

Posts

63.00

Credits

Newbie

Rank: 1

Credits
63.00

 China

Post time: 2020-4-18 07:30:01
| Show all posts
Agree with the opinion ofcqgangMM ..

When the short is processed, it will be automatically converted to int.
Reply

Use magic Report

0

Threads

3

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-4-20 13:30:01
| Show all posts
Only 5 types of int uint long ulong decimal can participate in arithmetic operations
It only makes sense to specify the constant type, there is no problem of short type constants,
short can be implicitly converted to int automatically
Reply

Use magic Report

0

Threads

32

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-5-1 14:15:02
| Show all posts
short i = 1;
short j = i + 2;
The above code will compile error, I think the landlord means if there is a suffix can be written
short j = i + 2X;
There is no need for type conversion.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list