Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › How to round off by 2 decimal places in C++?
New Posts  All Forums:Forum Nav:

How to round off by 2 decimal places in C++? - Page 2

post #11 of 12
tompsonn mistyped and wanted to say it's 4 and 8 "bytes" not bits.

I only know for sure how it was in C from a long time ago:

float was a 32-bit wide floating point number
double was a 64-bit wide floating point number
long double was what used the full 80-bit of the x87 coprocessor

Those 80-bit numbers are strange. I don't know what happens today with long double because of that. Compilers should try to not touch x87 code in any case as it's weird and slow compared to SSE2 and AVX and stuff. But I don't think you can do 80-bit numbers without x87. SSE2 should only do 64-bit. So you should probably never touch long double.

It being 80-bit wide may seem weird and off today, but x87 started out in 16-bit processor times. Those 80 bits are just one 16-bit word added to 64 bits.
post #12 of 12
Quote:
Originally Posted by deepor View Post

tompsonn mistyped and wanted to say it's 4 and 8 "bytes" not bits.

I only know for sure how it was in C from a long time ago:

float was a 32-bit wide floating point number
double was a 64-bit wide floating point number
long double was what used the full 80-bit of the x87 coprocessor

Those 80-bit numbers are strange. I don't know what happens today with long double because of that. Compilers should try to not touch x87 code in any case as it's weird and slow compared to SSE2 and AVX and stuff. But I don't think you can do 80-bit numbers without x87. SSE2 should only do 64-bit. So you should probably never touch long double.

It being 80-bit wide may seem weird and off today, but x87 started out in 16-bit processor times. Those 80 bits are just one 16-bit word added to 64 bits.

You bet I mistyped! Thanks tongue.gif

On MSVC at least now, a "long double" is the same as a "double" - however they *are* two different types, so you must use either or.
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › How to round off by 2 decimal places in C++?