mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-07 08:15:48 +02:00
Bug 150862 - Patch from Warren Paul: Float values not displayed correctly in hex and decimal formats..
This commit is contained in:
parent
8e347bf561
commit
0b84053482
1 changed files with 9 additions and 8 deletions
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Mark Mitchell, CodeSourcery - Bug 136896: View variables in binary format
|
||||
* Warren Paul (Nokia) - 150860, 150864
|
||||
* Warren Paul (Nokia) - 150860, 150864, 150862
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.core.model;
|
||||
|
||||
|
@ -420,26 +420,27 @@ public class CValue extends AbstractCValue {
|
|||
|
||||
private String getFloatValueString( ICDIFloatValue value ) throws CDIException {
|
||||
float floatValue = value.floatValue();
|
||||
Float flt = new Float( floatValue );
|
||||
if ( flt.isNaN() || flt.isInfinite() )
|
||||
return ""; //$NON-NLS-1$
|
||||
long longValue = flt.longValue();
|
||||
if ( Float.isNaN(floatValue) )
|
||||
return "NaN"; //$NON-NLS-1$
|
||||
if ( Float.isInfinite(floatValue) )
|
||||
return "inf"; //$NON-NLS-1$
|
||||
|
||||
CVariableFormat format = getParentVariable().getFormat();
|
||||
if ( CVariableFormat.NATURAL.equals( format ) ) {
|
||||
return Float.toString( floatValue );
|
||||
}
|
||||
else if ( CVariableFormat.DECIMAL.equals( format ) ) {
|
||||
return Long.toString( longValue );
|
||||
return Long.toString( Float.floatToIntBits(floatValue) );
|
||||
}
|
||||
else if ( CVariableFormat.HEXADECIMAL.equals( format ) ) {
|
||||
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
|
||||
String stringValue = Long.toHexString( longValue );
|
||||
String stringValue = Long.toHexString( Float.floatToIntBits(floatValue) );
|
||||
sb.append( (stringValue.length() > 8) ? stringValue.substring( stringValue.length() - 8 ) : stringValue );
|
||||
return sb.toString();
|
||||
}
|
||||
else if ( CVariableFormat.BINARY.equals( format ) ) {
|
||||
StringBuffer sb = new StringBuffer( "0b" ); //$NON-NLS-1$
|
||||
String stringValue = Long.toBinaryString( longValue );
|
||||
String stringValue = Long.toBinaryString( new Float( floatValue ).longValue() );
|
||||
sb.append( (stringValue.length() > 32) ? stringValue.substring( stringValue.length() - 32 ) : stringValue );
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue