Questions tagged [mantissa]

The mantissa of a floating-point number is the value m in the representation m × 2ᵉ, where e is the exponent. Use this tag for questions specifically about the mantissa of a floating-point number. For questions about floating-point numbers, use the [floating-point] tag instead. Do not use this tag for questions relating to the Divmod Mantissa application server.

The mantissa or significand of a floating-point number is the value m in the representation m × 2e, where e is the exponent.

60 questions
28
votes
3 answers

How does double to int cast work in Java

I am new to Java, and wondering how does double to int cast work ? I understand that it's simple for long to int by taking the low 32 bits, but what about double (64 bits) to int (32 bits) ? those 64 bits from double in binary is in Double-precision…
peter
  • 8,333
  • 17
  • 71
  • 94
8
votes
2 answers

Convert mantissa and exponent into double

In a very high performance app we find the the CPU can calculate long arithmetic significantly faster then with doubles. However, in our system it was determined that we never need more then 9 decimal places of precision. So we using longs for all…
Wayne
  • 2,959
  • 3
  • 30
  • 48
7
votes
5 answers

Fractional Part of NSDecimalNumber

I'm using NSDecimalNumber to store a value for currency. I'm trying to write a method called "cents" which returns the decimal portion of the number as an NSString with a leading 0 if the number is < 10. So basically NSDecimalNumber *n =…
JamesB41
  • 703
  • 10
  • 20
7
votes
1 answer

GCC Handling Float comparison differently at different Optimization Levels

I have some simple code that is comparing two float values to illustrate a problem I see with GCC's optimization and am hoping someone can help me figure out why the output it produces is different under some repeatable circumstances. First, I…
Cynan
  • 73
  • 4
6
votes
1 answer

Why does the bit-width of the mantissa of a floating point represent twice as many numbers compared to an int?

I am told that a double in C++ has a mantissa that is capable of safely and accurately representing [-(253 − 1), 253 − 1] integers. How is this possible when the mantissa is only 52 bits? Why is it that an int16 is only capable of having a range of…
davidj361
  • 147
  • 7
5
votes
1 answer

Perl mantissa differ from other doubles

I'm trying to scan in a float: 13.8518009935297 . The first routine is my own, the second is MacOSX libc's strtod, the third is GMP's mpf_get_d() the forth is perls numeric.c:Perl_my_atof2(). I use this snippet to print the mantissa: union…
Konrad Eisele
  • 3,088
  • 20
  • 35
5
votes
3 answers

Why the most significant bit for a normalized number is always 1?

From Significand entry in Wikipedia : When working in binary, the significand is characterized by its width in binary digits (bits). Because the most significant bit is always 1 for a normalized number, this bit is not typically stored and is …
Geek
  • 26,489
  • 43
  • 149
  • 227
3
votes
1 answer

In Matlab how to use variables for the numbers in scientific notation (matissa and exponent)?

I am using Matlab and using numbers in scientific notation, which are represented with the letter e for the exponent. An example in Matlab: >> 2e5 ans = 200000 Now would like to work with numbers in scientific notation, but using variables to hold…
Vass
  • 2,682
  • 13
  • 41
  • 60
3
votes
3 answers

How to find mantissa length on a particular machine?

I'm wanting to find the number of mantissa digits and the unit round-off on a particular computer. I have an understanding of what these are, just no idea how to find them - though I understand they can vary from computer to computer. I need this…
Zachary Wright
  • 23,480
  • 10
  • 42
  • 56
3
votes
2 answers

How to change the the number of colorbar digits of the mantissa using offset notation

I have a contour plot in matplotlib using a colorbar which is created by from mpl_toolkits.axes_grid1 import make_axes_locatable divider = make_axes_locatable(axe) #adjust colorbar to fig height cax = divider.append_axes("right", size=size,…
Dukaaza
  • 47
  • 1
  • 8
3
votes
1 answer

calculate mantissa and exponent of scientific number in matlab

I want to find mantissa and exponent of a number in mat lab. Is there a function or way to calculate them? for example when the number is 0.0005 this function returns 5 for mantissa and -4 for exponent thank you
A.Mani
  • 71
  • 1
  • 9
3
votes
2 answers

vb.net mantissa and exponent calculation from double

Can anyone offer any advice on how to get the mantissa and exponent from a double in VB.net? I know I can do a string parse and some conversion to ints but I wondered if anyone had a mathematical equivalent formula that would allow me to do…
WizardsSleeve
  • 185
  • 2
  • 4
  • 11
2
votes
1 answer

Shader Time Uniform - clock_gettime being truncated

Take this function getting time as a double using clock_gettime: // return current time in milliseconds static double time_get_ms(void) { struct timespec res; #ifdef ANDROID clock_gettime(CLOCK_REALTIME_HR, &res); #else …
Halsafar
  • 2,540
  • 4
  • 29
  • 52
2
votes
1 answer

How does a variable using a Floating-point binary format stores the value 0.0

Basically I'm confused right now and can't find anything helpful on stackoverflow or through google search. I've been reading about how computers store differents data types in binary format to better understand C programming and general knowledge…
MatGeneral
  • 57
  • 6
2
votes
1 answer

Why does Swift report CGFloat.pi.significand to be exactly pi/2?

Running Xcode 11.3 Why is the significant component of pi equal to pi/2? print(CGFloat.pi.significand == CGFloat.pi/2). // true I expected the significant to be equivalent to the mantissa.. Did I miss something?
eharo2
  • 2,553
  • 1
  • 29
  • 39
1
2 3 4