| |

VerySource

 Forgot password?
 Register
Search
View: 947|Reply: 6

How to get the number of digits of a floating-point variable with a value?

[Copy link]

5

Threads

23

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-1-15 23:40:02
| Show all posts |Read mode
As the title
Reply

Use magic Report

0

Threads

36

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-1-21 00:36:01
| Show all posts
float 4 bytes
double 8 bytes
There is no way to know the number of digits after the decimal point
Reply

Use magic Report

5

Threads

23

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

 Author| Post time: 2020-1-21 22:00:02
| Show all posts
I have a way:
000 .... 1
000 ... 01
    .
    .
    .
1000000
Perform a bitwise AND operation with a floating point number. When you get zero, you will reach the highest bit, and you can know the number of digits. I do n’t know if it works. It seems more troublesome. I wonder if there is any function that directly returns the number of digits?
Reply

Use magic Report

5

Threads

23

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

 Author| Post time: 2020-8-27 10:15:02
| Show all posts
It is easy to judge after converting to CString
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-27 10:30:01
| Show all posts
No ready-made functions available
You can only write functions yourself
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-27 10:45:01
| Show all posts
Convert it to a string type first, and then use getlength.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-27 11:00:01
| Show all posts
Digits? The number of digits in the system is set. This is set.
Float is 32-bit under 32-bit system
1 digit for the number, 8 digits for the order code, and 23 suffix codes;
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