Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. object to string (with 15 digit precision if decimal) [modified]

object to string (with 15 digit precision if decimal) [modified]

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    T2102
    wrote on last edited by
    #1

    I want to convert an object to a string and if it is a float, double, etc,,, then I would want to set the precision like I can with a printf statement. What would be an efficient way to test if a System::Object is some decimal type and then set the precision? Thanks //I've tried the following, but it does not work properly switch (System::Type::GetTypeCode(columnYValues[n]->GetType())) { case System::TypeCode::Decimal: case System::TypeCode::Double: case System::TypeCode::Single: X=System::String::Format( "{0:f15}", columnYValues[n]->ToString() ); break; default: X = columnYValues[n]->ToString(); } I am trying to create pivot tables using decimal headers and half of the time it does not work because of C++ .NET or ADO .NET's string conversions and zero tolerance.

    modified on Friday, April 9, 2010 2:38 AM

    A 1 Reply Last reply
    0
    • T T2102

      I want to convert an object to a string and if it is a float, double, etc,,, then I would want to set the precision like I can with a printf statement. What would be an efficient way to test if a System::Object is some decimal type and then set the precision? Thanks //I've tried the following, but it does not work properly switch (System::Type::GetTypeCode(columnYValues[n]->GetType())) { case System::TypeCode::Decimal: case System::TypeCode::Double: case System::TypeCode::Single: X=System::String::Format( "{0:f15}", columnYValues[n]->ToString() ); break; default: X = columnYValues[n]->ToString(); } I am trying to create pivot tables using decimal headers and half of the time it does not work because of C++ .NET or ADO .NET's string conversions and zero tolerance.

      modified on Friday, April 9, 2010 2:38 AM

      A Offline
      A Offline
      Andreoli Carlo
      wrote on last edited by
      #2

      try with the following: System::Convert::ToInt32 System::Convert::ToDouble System::Convert::To......

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups